211k views
2 votes
What does a copy constructor take as its one parameter?

a. An object of the same class
b. A constant reference to an object of the same class
c. A pointer to an object of the same class
d. A value of the same class

1 Answer

7 votes

Final answer:

A copy constructor takes a constant reference to an object of the same class.

Step-by-step explanation:

The correct answer is b. A constant reference to an object of the same class. A copy constructor is a special constructor that is used to create a new object as an exact copy of an existing object. It takes a constant reference to an object of the same class as its parameter. This allows the copy constructor to access and copy the values of the member variables from the existing object to the new object.

User Marti Nito
by
8.0k points