Which of the following can be declared inside an unnamed class in C++?

Options

  • A. Data members
  • B. Member functions
  • C. Access specifiers
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

D. More than one of the above

Detailed Explanation

Answer: (D) More than one of the above

An unnamed class can contain normal class members such as data members and member functions.

It can also use access specifiers such as public, private and protected.

For example:

class {

public:

  int value;

  void show() { }

} obj;

Therefore, all three listed features are possible.