RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TInterfacedObject::NewInstance Method

Allocates memory for each instance of an interfaced object.

Pascal
class function NewInstance: TObject; override;
C++
TObject NewInstance();

All constructors call System::TInterfacedObject::NewInstance automatically. System::TInterfacedObject::NewInstance calls System::TObject::InstanceSize to determine how much memory to allocate from the heap to contain a particular instance. Do not call System::TInterfacedObject::NewInstance directly. 

System::TInterfacedObject::TInterfacedObject overrides System::TInterfacedObject::NewInstance to increment the reference count when a new instance is created. This prevents any constructor from accidentally deleting the instance due to a System::TInterfacedObject::RefCount of zero. The System::TInterfacedObject::AfterConstruction method decrements the value of System::TInterfacedObject::RefCount after all constructors have executed. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!