Definitions

A definition is a unique specification of an object or variable, function, class, or enumerator. Because definitions must be unique, a program can contain only one definition for a given program element. Note that because declarations can occur more than once in a program, classes, structures, enumerated types, and so on can be declared for each compilation unit. The constraint on this multiple declaration is that all declarations must be identical.

There can be a many-to-one correspondence between declarations and definitions. There are two cases in which a program element can be declared and not defined:

A function is declared but never referenced with a function call or with an expression that takes the function's address.

A class is used only in a way that does not require its definition be known. However, the class must be declared. The following code illustrates such a case:

class WindowCounter; // Forward reference; no definition

class Window

{

static WindowCounter windowCounter; // Definition of

// WindowCounter

// not required.

};