#include using namespace std ; class Demo { private: int z1 ; public: int x1 ; int x2 ; string name ; int* ptr ; Demo(string nameP ) { name = nameP ; cout << "Inside the construtor method."<< name << endl ; ptr = new int[10] ; } Demo(const Demo& demoObj ) { cout << "Inside the copy constructor method." << demoObj.name << endl ; ptr = new int[10] ; name = demoObj.name ; //We have access to another object of the same class's //private data. x1 = demoObj.z1 ; } ~Demo() { cout << "Inside the destructor method:" << name << endl ; delete[] ptr ; } }; void function1( Demo obj1 ) { cout << "Inside function1" << endl ; } int main() { { Demo demo1("Local1" ) ; cout << "Step1:" << endl ; function1( demo1 ) ; cout << "Step2" << endl ; } }