Which keyword is used to define a class in C++?
Options
- A. struct
- B. class
- C. object
- D. More than one of the above
- E. None of the above
Quiz Practice:
B. class
Answer: (B) class
The class keyword is used to define a class in C++.
For example:
class Student {
int marks;
};
Here, class tells the compiler that a class definition is beginning.
C++ also supports struct for defining class-like types, but the keyword specifically used in the example above is class.