Machine-translated by Google. Questions are authored in English.
Top

Discussion

A class in C++ can have the following

  • A.One CONSTRUCTOR and one DESTRUCTOR
  • B.One CONSTRUCTOR and multiple DESTRUCTORS
  • C.Multiple CONSTRUCTORS and one DESTRUCTOR
  • D.Multiple CONSTRUCTORS and multiple DESTRUCTORS

Answer: C

A class can have Multiple CONSTRUCTORS and one DESTRUCTOR.

Constructors can be overloaded: a class may have a default constructor, parameterised constructors and a copy constructor, distinguished by their parameter lists. A destructor takes no arguments and cannot be overloaded, so a class has exactly one.

'One constructor' understates what overloading allows, and any option with multiple destructors is impossible, because ~ClassName() has a single fixed signature.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.