class is used to declare classes—C++'s basic unit of encapsulation. Its general form is shown here:
class class-name : inheritance-list {
// private members by default
protected:
// private members that can be inherited
public:
// public members
} object-list;
Here, class-name is the name of the new data type being generated by the class declaration. The inheritance-list, which is optional, specifies any base classes inherited by the new class. By default, members of a class are private. They may be made protected or public through the use of the protected and public keywords, respectively.
The object-list is optional. If not present, a class declaration simply specifies the form of a class. It does not create any objects of the class.
| Note |
For additional information on class, see Chapter 1. |