Answer Posted / sandip
To avoid local copy of object reference (&) is used in copy
constructor.
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.
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
What is a standard template library (stl)? What are the various types of stl containers?
What is stl in c++ with example?
Is string part of stl?
What are the different types of stl containers?
What are the components of stl?
What is a stl vector?
What are stl algorithms?
What is stl stack?
What is a list in c++ stl?
How does an stl file work?
What two types of containers does the stl provide?
how to use C++?
What is the stl, standard template library?
Explain stl.
Who wrote stl?