#pragma warning(disable : 4996) #include #include using namespace std; class str { public : char* p; int size; str(int sz) { p=new char[size=sz] ; cout << " Constructor &p " << &p << " p = " ; cout << p << endl; } ~str() { cout << " Destructor &p " << &p << " p = " ; cout << p << endl; delete[] p; } }; /* Initialising a string by assignment from another string and calling the copy constructor */ void foo() { str s1(10); strcpy(s1.p,"abcdefghi"); cout << " Address of s1 " << &s1 << endl; cout << " s1.p " << s1.p << endl; str s2=s1; cout << " Address of s1 " << &s1 << endl; cout << " s1.p " << s1.p << endl; cout << " Address of s2 " << &s2 << endl; cout << " s2.p " << s2.p << endl; return; } int main() { int i; cout << " Program starts \n"; foo(); cout << " Back in main - "; cout << " Type an integer to continue \n"; cin >> i; return(0); }