Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
Page 1 of 1
Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
#2 Guest_Rmn_*
Posted 14 December 2009 - 09:48 AM
vikas, on 11 December 2009 - 08:48 AM, said:
Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
Agreed- Question more clearely is,weather we can pass by value rather than reference in a copy constructor. No we can not pass data by value in a copy constructor.Since by its defination it must except a reference to copy both the locations byte by byte.
Page 1 of 1

Sign In
Register
Help
Start a new topic
Add Reply
MultiQuote
