What is the main limitation of an unnamed class regarding constructors?

Options

  • A. It cannot have any data members
  • B. It cannot declare a normal constructor using a class name
  • C. It cannot have member functions
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. It cannot declare a normal constructor using a class name

Detailed Explanation

Answer: (B) It cannot declare a normal constructor using a class name

A normal C++ constructor has the same name as its class. For example, if the class is named Student, its constructor can be named Student().

An unnamed class has no class name, so there is no class name that can be used for an ordinary constructor declaration.

However, this does not mean that an unnamed class cannot contain data members or member functions.