Basic Concept Understanding
1. The bool type represents true and false for truth. You can assign any value of the arithmetic type to bool exclusive. A 0-value arithmetic type represents false, and any value other than 0 represents true (why do you often do that, Khan!) )。 You can also assign a value to a bool variable directly with false or true.
2. C + + recommends that each built-in variable be initialized. Although this is not necessary, it is easier and more secure.
3, unlike other variables, unless specifically stated, the const variable declared in the global scope is a local variable that defines the file of the object. This variable exists only in that file and cannot be accessed by other files.
By specifying the const variable as extern, you can access the const object throughout the program. The non-const object defaults to extern.
4. The header file typically contains the definition of the class, the declaration of the extern variable, and the declaration of the function.
Because header files are typically contained in multiple original files, they should not contain definitions of variables or functions. But there are three exceptions to this rule:
(1) The class can be defined in the header file;
(2) You can define a const object to which the value is known at compile time;
(3) You can define an inline function.
5. Enumeration type
The first member of the object is assigned a value of 0 by default, and the value assigned by each enumeration member is 1 larger than the preceding one.
The value of an enumeration member cannot be changed, and the enumeration member itself is a constant expression, so it can also be used anywhere where constant expressions are required;
Each enum defines a new, unique type;
The initialization assignment of an enum-type object can only be done by its enumerated members or by other objects of the same enumeration type.
6.
class Type
The definition of Class 6.1 begins with the keyword class, followed by the name identifier of the class. The class body is inside the curly braces. The curly braces must be followed by a semicolon;
6.2 Data members and member functions
The class defines the data and operations that make up the type, which is part of the class, also known as a member of the class, and the operation is called a member function, and the data is called a data member;
The 6.3 class does not initialize the data members when defining the data members in the class definition, but rather controls the initialization by the special member function of the constructor ;
6.4 Public and private
A member of a public defined in a class can be accessed in any part of the program. Generally, the operation is placed in the public section so that any code of the program can perform these operations.
private defined members can only be accessed by code that is part of a class.
6.5 Class and struct
If you use the Class keyword to define a class, any members that are defined before the first access label are implicitly specified as private, and if you use the struct keyword, those members are public. Use the class and public keywords to define classes, only affecting the default initial access level.
Basic concept Understanding (II.)