--- On Sat, 11/8/08, Robert Ryan <[EMAIL PROTECTED]> wrote:

From: Robert Ryan <[EMAIL PROTECTED]>
Subject: [c-prog] diff between
To: [email protected]
Date: Saturday, November 8, 2008, 11:43 AM






what is the difference between a constructor and a default constructor 
and a destructor and delete[]
does a constructor always have a destructor and a delete appears when no 
constructor is created
thanks
bob
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
constructor is defined in a class which initialises the object of the class 
where as default constructor isnt defined in the class. but allocates memory to 
the objects of the class. but with garbage value initializtions.
where as destructor and delete both deallocate the memory.Delete operator 
destroys the object created with new by deallocating the memory associated with 
the object. The delete operator has a void return type.
The result of deleting an array object with delete is undefined, as is deleting 
an individual object with delete[]. The array dimensions do not need to be 
specified with delete[].
If a destructor has been defined for a class, delete invokes that destructor. 
Whether a destructor exists or not, delete frees the storage pointed to by 
calling the function operator delete() of the class if one exists.
a destructor function will deallocate memory if and only if it has been defined 
in the class.the delete operator calls the destructor function to deallocate 
the memory, so even if the destructor isnt defined, the delete opertaor ll call 
the default destructor
 









[Non-text portions of this message have been removed]

 














      

[Non-text portions of this message have been removed]

Reply via email to