Constructor & Destructor

4

Constructor :As name suggest, it construct an object. Constructor is used to initialize the data members of a class.Consider a class below:#include #include using namespace std;class employeeData { unsigned int m_salary; char* m_name;public: ~ employeeData() { //Destructor if (m_name) { delete []m_name; } } employeeData() { // default constructor cout

Read this post on allabouttechnologies.co.in


Karan Arora

blogs from Chandigarh