#Previous question #Index of C++ Questions #Next question

Shallow Copy:
Default copy constructor of compiler copies all the member variables from source to destination object. This is called shallow copy constructor.

Example:

#include<string.h>
#include<iostream.h>
class C
{
  public:
  int var1;
};
void main(int argc, char *argv[])
{
  C c1;
  c1.var1 = 1;
  C c2(c1);
  cout << "value of c2.val " << c2.val;
}

You have viewed 1 page out of 62. Your C++ learning is 0.00% complete. Login to check your learning progress.

Most popular topics (must visit)

Useful links for students