Standard Template Library (STL) Question:
Download Questions PDF

Why & sign is used in copy constructor?


To avoid local copy of object reference (&) is used in copy
Moreover if the & is ommited then copy constructor goes in
infinite loop.
eg. if class name is Sample.

Copy constructor without &
Sample :: Sample (Sample s)
//Code goes here

and we create object as follows. ;
Sample s;
Sample s1(s);

In this scenario program will go in infinite loop.

Download Standard Template Library (STL) Interview Questions And Answers PDF

Previous QuestionNext Question
#define CUBE(x) (x*x*x)
{ int a,b=3;
printf("%d %d",a,b);
What should be the value of a and b? My calc a=4 but syst
a=6 how pls tell me if you know it?
What is electronic software?