Wednesday 24 August 2016

C++ Copy Constructor

What is a difference between copying and cloning an object?
What is a copy constructor? (What is its purpose?)
What are its arguments?
What is implicit and what is user-defined copy-constructor?
When does compiler create copy-constructor?
When is needed a user-defined copy-constructor? Why? What else is then also needed?
What is the Rule of three?
Is there any other way to copy objects apart from using copy-constructor?
Give some examples of copy constructor signatures. Which one is preferred?
Which versions of copy constructor are called in the following code snippet?
a) X x = X(); 
b) const X x1;    
   X x2 = x1;
Why are these constructors not valid copy-constructors?
a) X(X x) 
b) X(const X x)
In which situations is called copy-constructor? (List 5 cases of copy-initialization.)
What is Return value optimization?

TBC...

References:

http://stackoverflow.com/questions/2200409/what-is-the-difference-between-copying-and-cloning
https://en.wikipedia.org/wiki/Object_copying
https://en.wikipedia.org/wiki/Cloning_(programming)
https://en.wikipedia.org/wiki/Copy_constructor_(C%2B%2B)
https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)

No comments:

Post a Comment