Source: C ++ primer P49 ~ 67
Level: 100
Const int I, j = 0;
Note: constants must be initialized during definition.
Extern const int bufsize = 100;
Note: The const variable declared in the global scope is an internal object by default. After the extern is added, it can be accessed across compilation units.
Int & refval = ival;
Note: After Non-const references are initiated, they are always bound to this object. And the type must be the same as the bound object.
Double dval = 1.1;
Const Int & rI = dval;
Note: const references can be bound to different but related types.
Enum points {point2d = 2, point2w, point3d = 3, point3w}; // 2, 3, 3, 4
Points pt2w = 3; // Error
Note: The value assignment is invalid even if 3 is a value in the points enumeration.
Class sales_item {};
Note: The class definition is followed by a semicolon.
The only difference between class and struct keywords
Note: by default, the struct member is public and the class member is private.
The header file should not contain definitions.
Note: three exceptions: Definition class, const object, and inline function.