Class Types
Go Up to Classes Index
The declaration creates a unique type, class type class-name. This lets you declare further class objects (or instances) of this type, and objects derived from this type (such as pointers to, references to, arrays of class-name, and so on):
class X { ... }; X x, &xr, *xptr, xarray[10]; /* four objects: type X, reference to X, pointer to X and array of X */ struct Y { ... }; Y y, &yr, *yptr, yarray[10]; // C would have // struct Y y, *yptr, yarray[10]; union Z { ... }; Z z, &zr, *zptr, zarray[10]; // C would have // union Z z, *zptr, zarray[10];
Note the difference between C and C++ structure and union declarations: The keywords struct and union are essential in C, but in C++, they are needed only when the class names, Y and Z, are hidden (see Class name scope)