1. List of constructors available for initialization:
Book: Book (): size (100), weight (50) {}// suppose Size weight is int type class name book
2. If the default constructor (or constructor created by the compiler) is used:
A. if the object is defined in the global scope (not in any function), or is defined as a static local object, the class type is initialized by the constructor, and the member variable of the built-in type is initialized to 0.
B. if the object is defined in a local scope: the class type is initialized by the constructor, and the member variables of the built-in type are not initialized
For example,
Assume that the book class has a member variable of the int type, then:
Int main () {book; cout <book. Size <Endl; // The result shows no initialization}
And:
Int main ()
{
Static book;
Cout <book. Size <Endl; // The result is 0.
}
Or
Book; int main () {book; cout <book. Size <Endl; // The result is 0}