Which statement correctly describes an unnamed class in C++?

Options

  • A. It must always have a class name
  • B. It can be defined without specifying a class name
  • C. It can never contain data members
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. It can be defined without specifying a class name

Detailed Explanation

Answer: (B) It can be defined without specifying a class name

An unnamed class is a class whose definition does not specify an identifier after the class keyword.

For example:

class { public: int value; } obj;

Here, the class itself has no name, but an object named obj is declared from that class definition.

The class can still contain data members and member functions.