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.



Explore posts in the same categories: C/C++ Interview Questions


BOOKMARK THIS : del.icio.us | Digg it | Furl | reddit |


Related Questions :

  • What is the difference between a copy constructor and an overloaded assignment operator?
  • A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns...
  • What is copy constructor?
  • Constructor which initializes the it's object member variables ( by shallow copying) with another object of the same class. If you...
  • Differentiate between a deep copy and a shallow copy?
  • Deep copy involves using the contents of one object to create another instance of the same class. In a deep...
  • Objects are passed by value or by reference ?
  • Java only supports pass by value. With objects, the object reference itself is passed by value and so both the...
  • Differentiate between a deep copy and a shallow copy?
  • Deep copy involves using the contents of one object to create another instance of the same class. In a deep...
  • What is Constructor ? How it is called ?
  • Constructor is a member function of the class, with the name of the function being the same as the class...
  • When are copy constructors called?
  • Copy constructors are called in following cases: a) when a function returns an object of that class by value b) when the...
  • What is Value type and refernce type in .Net?
  • Value Type : A variable of a value type always contains a value of that type. The assignment to a...
  • What is the difference between a Struct and a Class ?
  • The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to...
  • Can I call a virtual method from a constructor/destructor?
  • Yes, but it's generally not a good idea. The mechanics of object construction in .NET are quite different from C++,...

    Comment:

    You must be logged in to post a comment.