Follow this blog by Email

Sunday, 14 July 2013

                                      C++ Copy constructors   

Copy constructor is a special type of constructor invoked when initializing an object of a class when the object is created. During the creation, if  a implicit type conversion happens, due to arguments  passed to the object of a class during, the copy constructor needs a const reference as its argument in the constructor definition and declaration, else the compiler complains as it is a violation of standard[To paraphrase the relevant clause in C++ Standard: "An rvalue cannot bind to a non-const reference. "

The below post explains the problem in simple terms:-

No comments: