C++ classes
A class in C++ is a user-defined type or data structure declared with any of the keywords class
, struct
or union
(the first two are collectively referred to as non-union classes) that has data and functions (also called member variables and member functions) as its members whose access is governed by the three access specifiers private, protected or public. By default access to members of a C++ class declared with the keyword class
is private. The private members are not accessible outside the class; they can be accessed only through member functions of the class. The public members form an interface to the class and are accessible outside the class.
Instances of a class data type are known as objects and can contain member variables, constants, member functions, and overloaded operators defined by the programmer.