why & sign is used in copy constructor
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / neha
Here as address of the object is taken into consideration
thats why here & sign is used
| Is This Answer Correct ? | 7 Yes | 3 No |
Answer / krishnarao panchadi
Sandip, Good answer. It goes into Infinete loop because, as
the a local copy of the object is created, it will call the
constuctor one more time and another copy will be created
there and so on...
| Is This Answer Correct ? | 2 Yes | 0 No |
What is the disadvantage of templates ?
What are the various types of stl containers?
Who wrote stl?
write a c++ to define a class box with length,breadth and height as data member and input value(),printvalue() and volume() as member functions.
What does stl mean in slang?
Define the terms: field, record, table and database
Name the different types of stl containers.
What is the underlying datastructure of map?
Find the error in the following program struct point {struct point *next; int data; } x; main() {int...data; } x; main() {int i; for(x=p;x!=0;) x=x->next,x++; freelist(x); } freelist(x) {free(x); return }
What is the stl, standard template library?
WHAT IS FIBONACCI SERIES?
To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command