// CPPProg.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; #include <string> class Employee { public: char *empName; int empRolNo; public: Employee() { delete []empName; cout<<"Default Constructor"<<endl; empName = new char[3]; strcpy_s(empName,strlen("aa") + 1,"aa"); empRolNo = 10; Employee e5; } Employee(char *name,int r) { cout<<"Param Constructor\t"<<this<<endl; this->~Employee(); empName = new char[strlen(name) + 1]; strcpy_s(empName,strlen(name) + 1,name); empRolNo=r; Employee e1; } virtual ~Employee() { cout<<"Desstructor\t"<<this<<endl; delete []empName; empName=NULL; } }; int _tmain(int argc, _TCHAR* argv[]) { Employee e1,e2("Satya",123); getchar(); return 0; }
Employee
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)