|
Constructor |
Destructor |
| 1- |
It is Used to Initialize the Object. |
It is used to destroy the object that are created in memory previously. |
| 2- |
Constructor has same name as class name. |
Destructor has same name as class name with tiled operator. |
| 3- |
Constructor overloading can be possible means more than one constructors can be defined insame class. |
Destructor can not be overloaded. |
| 4- |
Constructor accepts argument. |
Destructor can not take any arguments. |
| 5- |
Constructors can be used to dynamically initialize the memory. |
Destructor can be used to deallocate the memory. |
| 6- |
Constructor indirectly use the New operator to initialize the object. |
Destructor indirectly use the Delete operator to destroy the object initialize by constructor. |
| 7- |
Constructor are of following:
1)Default Constructor.
2)Parameterized Constructor.
3)Copy Constructor. |
Destructor has no any types. |
| 8- |
Syntax of constructor :
class ConstructorClass
{
ConstructorClass(){}
ConstructorClass(argulist){}
} ; |
Syntax of Destructor:
class DestructorClass
{
~DestructorClass(void){}
};
|