C ++ does not directly define any input or output statements, which are provided by the standard library.
The standard library defines four IO objects.
They are:
Cin standard input stream
Cout standard output stream
Cerr standard error stream
Clog standard error stream
Generally, the system executes these objectsProgramIn this way, when we read data from Cin, the data is read from the window of the execution program.
When reading cerr, clog, and cout, the data is first transmitted in the same window.
When most operating systems are running, they define methods to redirect input and output streams. The redefinition method can be used to associate these watershed objects.
In C ++, each expression has a result, which usually acts the output operator on the value produced by its operand. When the operator is an output operator, the result is the value of the Left operator, that is to say, the value returned by the output operation is output Liu.
Endl is a special operator. In addition to line breaks, it can also refresh the buffer associated with the device. By refreshing the buffer, you can immediately see the output written to the stream. In special use of Endl, the output statements inserted by programmers during the book picking process should be to refresh the output stream ,. That is, Endl
About namespaces: Using namespaces allows programmers to avoid conflicts caused by accidental use of the names defined in the library with the same name, because the names in the standard library are defined in the namespace, therefore, programmers can use the same name in their own namespaces.
For the definition of variable initialization, the initial value should be assigned to the variable when defining the variable, unless it is determined that the variable will overwrite the initial value before other intentions are used. If the variable cannot be reset before reading the variable, initialize the variable