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 a standard template library (stl)?
Distinguish between: a) Normal layout & Print Layout views b) Windows Clipboard & office Clipboard c) Save & Save As Commands d) Program File & Data File e) Pie Charts & Barr Charts
method overloading means what?
What is the stl, standard template library?
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
What is Constructor
5. Write c++ function that would intake a string and return the number of occurrences of a given character in that sring Ex:- if the word is “Colombo” and count the occurrences of the letter “o” the function would return 3
Write a program in C++ to concatenate two strings into third string using pointers
How can you create a bulleted list, numbered list and an outline by using bullets and numbering command. Explain with the help of example.
i want a road rash 3d game code if some one know please help me
What is the disadvantage of templates ?
I am doing my BS.c MATHS CAN I ABLE TO JOIN IN NIIT?