Share via


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 name of a class may be either an identifier or a template identifier. See Templates.

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.

  • A "destructor" function, which performs 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:

For information on managed classes and structs, see Classes and Structs.

See Also

Reference

Classes, Structures, and Unions