Classes - What are they?


A class is a generalised type and constitutes the definition of an object.

int i declares i to be a variable of type int.

Vector2 v declares v to be an object of type (class) Vector2.

Objects of a given class are constructed at run time.


Classes define how objects of the class are initialised and destroyed using special functions called constructors and destructors.

Vector2(1.5,2.0) constructs an object of class Vector2.


The class contains the member functions and data which constitute the internal representation and implementation of the object and the member functions which provide the interface to the object.
The class controls the visibility of the data members. Members may be publicly accessible to anyone or only accessible to class member functions. The class designer decides.
The class controls the accessibility of the member functions. Functions which are publicly accessible constitiute the user interface. Functions which are only accessible within the class hide implentation details. Again, it is the class designer who decides.
cont...