#include using namespace std; class MyClass { private: int *value; public: MyClass() // default constructor { *value = 0; cout<<"Default Constructor setting value to " << *value << endl << endl; } MyClass(int i) // constructor { value = new int; *value = i; } MyClass(const MyClass &other) // copy constructor { // value = i.value; cout << "Inside Copy Constructor...." << endl << endl; cout << "b's original value is: " << *value << endl; cout << "a's value is: " << *other.value << endl << endl; } ~MyClass() // destructor { delete value; cout << "In destructor... "<< endl; } int PrintValue() { return *value; } }; int main() { MyClass a = MyClass(3); // this does not use a pointer MyClass b = a; // Copy Constructor is invoked automatically MyClass *c = new MyClass; // this allocates memory for the object - NO copy constructor *c = a; // c already has its own memory cout << "c value is: " << c->PrintValue() << endl << endl; delete c; getchar(); }