|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Overview of Classes
Class types are defined using the class, struct, and union keywords. For simplicity, types defined with these keywords are called class declarations, except in discussions of language elements that behave differently depending on which keyword is used.
Names of classes defined within another class ("nested") have class scope of the enclosing class.
The variables and functions of a class are called members. When defining a class, it is common practice to supply the following members (although all are optional):
- Class data members, which define the state and attributes of an object of the class type.
- One or more "constructor" functions, which initialize an object of the class type. Constructors are described in Constructors.
- One or more "destructor" functions, which perform cleanup functions such as deallocating dynamically allocated memory or closing files. Destructors are described in Destructors.
- One or more member functions that define the object's behavior.
For more information, see: