The fundamental building block of OO software.
classdefines a data type, much like a
structwould 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
intis a type because it has both a set of states and it has operations like
i + jor
i++, etc. In exactly the same way, a
classprovides 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.
You can imagine that
classthat has member functions called
operator++, etc. (
intisn’t really a
class, but the basic analogy is this: a
classis a type, much like
intis a type.)
Note: a C programmer can think of a
classas a C
structwhose members default to
private. But if that’s all you think of a
class, then you probably need to experience a personal paradigm shift.