O'Reilly logo

Mastering C++ Programming by Jeganathan Swaminathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code walkthrough - Part 1

As you may have understood from the MyClass definition, it has defined the default constructor, copy constructor and destructor, an assignment operator, and sayHello() methods, as shown here:

//Definitions removed here to keep it simple class MyClass {public:      MyClass() { }  //Default constructor      ~MyClass() { } //Destructor       MyClass ( const MyClass &objectBeingCopied ) {} //Copy Constructor       MyClass& operator = ( const MyClass &objectBeingAssigned ) { } //Assignment operator      void sayHello();}; 

The methods of MyClass have nothing more than a print statement that indicates the methods got invoked; they were purely meant for demonstration purposes. 

The main() function creates two auto_ptr smart pointers that point to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required