Constructor:This is a member of class which involkes when the object is created.Purpose of constructor is to intialise the objects with required values.
Destructor: It is a member of class which involkes when the object is out of scope.The purpose of destructor is to clear the heap memory.
Submitted by divya e (mail2_divya@yahoo.com)
constructor is a special function, with the same name of the class, with no return type, and is automatically invoked when an object of that class is created; it is used to initialize the object / object variables;
Destructor has the same name of the class but preceded with a tilda(~) symbol; it is used to destroy or free the memory allocated for the object; it is automatically called when an object is destroyed;;
Both are members of class only.But the constructor is one which initialized some values with some required values and destructor is one one which clear the heap memory.
constructor is a special function, with the same name of the class, with no return type, and is automatically invoked when an object of that class is created; it is used to initialize the object / object variables;
Destructor has the same name of the class but preceded with a tilda(~) symbol; it is used to destroy or free the memory allocated for the object; it is automatically called when an object is destroyed;;
Constructor: It used for inislize objects values .It hv same name as class name and Invoked when class is lode.
Destructor: It is also hv same name as class but used to remove address of a objects from heap memory and it is also run autometiclly when Objects is destroy or Class is unload.
constructor: its a special function with same name as that of class &it doesn't have return type it can be over loaded but their must be difference in no. of parameters even it is automatically called as object of class created. destructor: this function returns the memory by destroying whatever constructed by constructor &make it free to use. regards ankita
constructor is a function that has same name as of its class.it is defined with legal initial value whereas destructor is same as constructor but a prefix ~ is used
c++ we want to create user defined data type such as class to behave so closely like built in data type(int,float). and as we are able to initialize these built in data type at the time of their creation we must be able to do the same with class objects(of type class). so we use constructor to initialize the variables of type class i e objects
Constructor: is a function with the same name as of its class.it doesn't return any value neither void. Destructor:it's use to destroy the memory allocated for the object represented by "~"tilda operator. which is automatically called when an object destroyed
Contructor is a special member function that allows us to set up values while defining the object,without need to make a seperate call to a member function.
When an object is destroyed a function called Destructor.The most common use of destructors is to deallocate memory that was allocated for the object by the constructor
a constructor is a public member function which is used for initialising an object of a class when it is created...while a destructor is used to destroy the object when the control comes out of the block...