Contents Up << >>

What is a class?

The fundamental building block of OO software.

A class defines a data type, much like a struct would be in C. In a computer science sense, a type consists of both a set of states AND a set of operations which transition between those states. Thus " int" is a "type" because it has both a set of states AND it has operations like "add two ints" or "int*int", etc. In exactly the same way, a "class" provides a set of (usually public) operations, and a set of (usually non-public) data bits representing the abstract values that instances of the type can have. From a C language perspective, a class is a struct whose members default to " private".

Think of "int" as a class that has methods called " operator++", etc.