View RSS Feed

Sanvi

Copy constructors and assignement operators in c++

Rate this Entry
by , 04-01-2013 at 09:41 AM (4146 Views)
Copy Constructor
A copy constructor is a special constructor for a class/struct that is
used to make a copy of an existing instance.

The below are the syntaxes of the copy constructors


Code:
CopyConstructorExample( const CopyConstructorExample& other );
  CopyConstructorExample( CopyConstructorExample& other );
  CopyConstructorExample( volatile const CopyConstructorExample& other );
  CopyConstructorExample( volatile CopyConstructorExample& other );

Note that none of the following constructors, despite the fact that
they could do the same thing as a copy constructor, are copy
constructors:


Code:
  CopyConstructorExample( CopyConstructorExample* other );
  CopyConstructorExample( const CopyConstructorExample* other );

This is the another way to create an infinite loop:


Code:
  CopyConstructorExample( CopyConstructorExample other );

Submit "Copy constructors and assignement operators in c++" to Digg Submit "Copy constructors and assignement operators in c++" to del.icio.us Submit "Copy constructors and assignement operators in c++" to StumbleUpon Submit "Copy constructors and assignement operators in c++" to Google

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments