GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C++

 Print  |  
Question:  what is defference between constructor and destructor




January 01, 2009 20:35:12 #7
 rlee2008   Member Since: January 2009    Total Comments: 1 

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().

     

 

Back To Question