Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

why & sign is used in copy constructor

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


Please Help Members By Posting Answers For Below Questions

What is a standard template library (stl)? What are the various types of stl containers?

1111


What is stl in c++ with example?

1086


Is string part of stl?

1153


What are the different types of stl containers?

1075


What are the components of stl?

1052


What is a stl vector?

1157


What are stl algorithms?

1115


What is stl stack?

1071


What is a list in c++ stl?

1117


How does an stl file work?

1095


What two types of containers does the stl provide?

940


how to use C++?

2488


What is the stl, standard template library?

1038


Explain stl.

1304


Who wrote stl?

1080