1.
// new header files are not required. h, iostream and iostream.h are not the same using namespace std; int "Hello, world! " /* newline can also be used \n,<<endl with Endl when the buffer will be refreshed, so that things in the stack refreshed once, but with "\ n" will not be refreshed, it will only be wrapped */ return 0 ; }
Variable name is case sensitive
Programming languages that use static types are performing type checking at compile time, rather than performing type checking at run time.
2.
The Block annotation character (/*...*/) is not nested.
In addition, we can implement annotations using #if 0 ... #endif , and can be nested in the following format:
#if 0code#endif
You can change #if 0 to #if 1 to execute code .
This form of debugging can also help, test using #if 1 to execute the test code, after publishing the use of #if 0 to mask the test code.
The #if can be any conditional statement.
3.
The size of the variable varies depending on the compiler and the computer you are using.
4.
typedef declaration
You can use typedef to take a new name for an existing type. The following is a syntax for defining a new type using typedef:
For example, the following statement tells the compiler that feet is another name for int:
int feet;
5.
Enum type
An enumeration type (enumeration) is a derived data type in C + +, which is a collection of user-defined enumeration constants.
If a variable has only a few possible values, it can be defined as an enumeration (enumeration) type. The so-called "enumeration" refers to the value of the variable is enumerated, the value of the variable can only be listed in the range of values.
To create an enumeration, you need to use the keyword enum. The general form of an enumeration type is:
enum enumeration Name {Identifier [= integer constant], identifier [= integer constant],... Identifier [= integral type constant]} enumeration variable;
If the enumeration is not initialized, that is, when the = integer constant is omitted, the first identifier starts.
For example, the following code defines a color enumeration, and the type of variable c is color. Finally, C is assigned the value "blue".
Enum Color {red, green, blue} C;
c = blue;
By default, the first name has a value of 0, the second name has a value of 1, the third name has a value of 2, and so on. However, you can also assign a special value to the name, just add an initial value. For example, in the following enumeration, the value ofGreen is 5.
Enum Color {red, green=5, blue};
Here, the value ofBlue is 6 because, by default, each name is 1 larger than the previous name, but Red still has a value of 0.
6.
Variable declarations in C + +
A variable declaration assures the compiler that a variable exists with the given type and name so that the compiler can continue to compile further without knowing the full details of the variable. A variable declaration has its meaning only at compile time, and the compiler needs an actual variable declaration when the program is connected.
Variable declarations are useful when you use multiple files and define variables only in one of the files (the file that defines the variables is available when the program connects). You can declare a variable anywhere using the extern keyword. Although you can declare a variable multiple times in a C + + program, a variable can only be defined once in a file, function, or code block.
Similarly, when a function is declared, a function name is provided, and the actual definition of the function can be done anywhere.
7.
Lvalue (Lvalues) and Rvalue (Rvalues) in C + +
There are two types of expressions in C + +:
Lvalue (lvalue): An expression that points to a memory location is called an lvalue (lvalue) expression. The left value can appear to the left or right of the assignment number.
Rvalue (rvalue): The term Right value (rvalue) refers to a numeric value stored in memory for some address. An rvalue is an expression that cannot be assigned a value, that is, the right value can appear to the right of the assignment number, but not to the left of the assignment number.
8.
C + + variable scope
A scope is a region of a program, and there are generally three places where you can define a variable:
A variable declared inside a function or a block of code, called a local variable.
A variable declared in the definition of a function parameter, called a formal parameter.
A variable declared outside of all functions, called a global variable.
C + + learning (1)