Which of the following is a valid class declaration?
Step-by-step Solution:
- (a) class A {int x} : Invalid syntax as class members must be defined properly. \[\] - (b) class B { }: Valid syntax. This declares an empty class in C++. \[\] - (c) public class A}: Invalid syntax. The `public` keyword does not belong outside a scope. \[\] - (d) object A {int x;); : Invalid syntax. `object` is not a valid keyword in C++. \[\] \[\] Correct Answer The valid class declaration is: class B \ \[\] Correct Answer: (b)