RE: what is defference between constructor and destruc...
Constructor is called when a object is createdand Destructor is called when object goes out of scopeConstructor. is used to initilize the valuesDestructor. is uised to free the memory --
RE: what is defference between constructor and destruc...
constructor: it is used to construct the object of the class.it is called when object of the first class is instansiated.destructor: it is used while destroying the object.it is called automatically when close braces is encontered.
RE: what is defference between constructor and destruc...
constructor is the memeber function of the class which has the same name as that of class and it is invoked whenever the class object is instantiated.
destructor is also the member function of same class name and has ~ operator when ever declared in the function and it is used to destruct the object which has been constructed whenever we want to destroy it..
RE: what is defference between constructor and destructor
Both Constructor and Destructor are member functions of the class. Both are made by the language defaultly and can be override by the programmer. The constructor is being called when a new object of the class is created- it can be used to initiate members to call functions and what ever is needed when an instance of the class is being made. The destructor is a function that is responsible for avoiding memory leak when deleteting an object. It's important to put a virtual befor constructors of base classes in order to avoid memory leak.
RE: what is defference between constructor and destructor
Constructor builds the object from the scratch where as destrcutor give the object its last rights (like for getting back the allocated memory). Constructor gets called when the object was created and destructor gets called automatically when the object goes out of scope.
RE: what is defference between constructor and destructor
A constructor of a class is mainly responsibly for turning the raw memory allotted to an object into a usable object. DEFAULT CONSTRUCTOR: The default constructor is a constructor that takes no argument. Part::Part() String() and String(const char* str) can be combined into a single constructor that has a default argument: String(const char* str 0)
for every class there can be only one default constructor.
COPY CONSTRUCTOR: A copy constructor is a special constructor that can be called to copy an object. The copy constructor for class Part has the form Part::Part(const Part&).
DESTRUCTOR: Whenever an object goes out of scope it is destroyed and the memory used by that particular object will be reclaimed. Part::~Part().