Constructor A member function with the same name as the class.It initializes the data members of a class object.Called automatically when an object of that class is created.There can be many constructors accomplished through function overloading.Specifying a return type or a return value for a constructor is a syntax error.Default Constructor is a constructor with no parametersThe default constructor takes no parameters, whether you declare it or get it free fromthe compiler If you declare any constructor, the compiler will not provide a default constructor Once the class has been defined, it can be used as a type in object, array, pointer or areference.Time sunset, arrayoftimes, *ptrToTime,&dTime=sunset
------- C++ is extensibleData members may be private as they may be of no concern to class’ clients. Thus,implementation is hidden and this information hiding promotes program modifiability andsimplifies the clients’ perception of a class.Member functions are usually shorter than non-object oriented programs because thedata stored in data members have ideally been validated by a constructor and/or bymember functions that store new data. Because the data are already in the object, themember function calls often have no arguments or atleast few arguments than typicalfunction calls in non object oriented languages. Thus, the calls are shorter, functiondefinitions are shorter and function prototypes are shorter.Attempting to initialize a data member of a class explicitly in a class definition is a syntaxerror.Destructor A member function the same name as the class and with prefix ~ i.e. ~className( );If no destructor is specified then the system ‘plugs-in’ one destructor.The destructor does ‘termination housekeeping’ on each class object before the memoryfor the object is reclaimed by the system.Destructors cannot take arguments and hence, cannot be overloaded.Destructors have no return value.Declaring member functions inside a class definition (via their function prototypes) &defining those member functions outside the class definition separates the interface fromof a class from its implementation. This promotes good Software Engineering as it hidesimplementation from class’ clients and also class’ need not recompile if implementationchanges; provided interface remains same. Member functions declared outside in aclass definition can be defined outside class definition using binary scope resolutionoperator ::. If member function is defined outside then use of class name and :: ismandatory as it ties function to a class and two classes may have functions with samename. However, scope of such functions is that of class only.