1.

Which of the following is a valid class declaration?(a) class A { int x; };(b) class B { }(c) public class A { }(d) object A { int x; };This question was posed to me in a national level competition.This key question is from Classes topic in chapter Source Files, Classes and Operator Overloading in C++ of C++

Answer»

The CORRECT OPTION is (a) class A { int x; };

For explanation: A class declaration TERMINATES with SEMICOLON and starts with class keyword. only option (a) FOLLOWS these rules therefore class A { int x; }; is correct.



Discussion

No Comment Found

Related InterviewSolutions