Constructor
|
Destructor
|
Constructor name is similar to a class name.
|
Destructor name is also similar to a class name but the major
difference is that destructor name is followed by a tilt sign(~).
|
Constructor does not have a return type like a member function.
|
Destructor does not have a return type too.
|
Constructors are the first thing that is being called when an
object of that class is created.
|
Destructors are the last thing that is being called when an
object of that class goes out of scope.
|
There can be multiple constructors inside a class i.e.
constructors can be overloaded (changing the parameter list).
|
A class can have only one destructor as destructors do not take
an argument.
|
Sunday, 7 October 2012
What is the difference between a constructor and a destructor
Subscribe to:
Post Comments (Atom)
Is destructor present in Java also?
ReplyDeleteDestructors are not present in Java...
ReplyDelete