-=> Quoting Fran‡ois De Mey to Christian S. Pedersen
FDM> Hi coder...
CSP> If I "delete" a Class, allocated with "new", will the Class'
CSP> destructor be called ?
CSP> Christian...
FDM> Yes, and more...
Nope.
FDM> If U allocate a Class with new in a block and that U don't destroy it
FDM> before end of block, the Class will be destroyed propely and the
FDM> destructor will be called.
Nope.
FDM> {
FDM> MyClass* Array;
FDM> Array = new MyClass[ 50 ];
FDM> }
FDM> Here, MyClass.~MyClass() will be called 50 times and memory will be
FDM> free.
Nope.
You must call delete[] explicitly. What _does_ do what you say is the
following:
{
MyClass Array[50];
}
MyClass::~MyClass() will be called for each of the 50 objects... right after
MyClass::MyClass() is.
new creates memory on the heap - which the compiler can't actually keep track
of. Your code must do it instead... and call delete or delete[] on it.
... I am Windoze of Borg. Your disk space will be assimilated.
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)
|