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 |
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
How is stl different from c++ standard library?
sir please send me bpcl previous question papers
0 Answers BPCL Bharat Petroleum,
What is the disadvantage of templates ?
why we are using the fork command?.. how it works?
What is meant by stl in c++?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?
How do I convert a stl file?
How Find, Replace and Go To commands ca be used to substitute one character string for another? Explain with the heIp of an example.
c# support late binding or early binding.
write a program that input four digit number and find how many 7 that number contains