1.1 Writing a simple C + + program
The main function is the only function that is explicitly called by the operating system
Compile execution
1.2 First Glimpse input/output
iostream: input/output stream
Istream:cin Read from window
Ostream:cout, Cerr, clog output to window
Write to stream
Std::cout << output Items << Std::endl; Write right operand to ostream
The output operator (<<) returns the value of the left operand, the operator (Endl) writes the output stream, wraps the line, and refreshes the buffer associated with the device. By flushing the buffer, you can immediately see the output written to the output stream.
Use a name from the standard library
Using namespaces (namespace), you can avoid inadvertently using names that are the same as the names in the library to cause conflicts
Scope operator (::) scope operator
Std::cin, Std::cout, Std::endl
Read the Inflow
Std::cin >> inputs >> Std::endl; Read data from IStream to right-hand operand
Input operator (>>) returns the value of the left operand
If you cannot guarantee to reset a variable before reading it, you must initialize the variable
1.3 About annotations
Comment to/* */double slash//
Not nested,/*/*/* * ERROR
1.4 Control Structure
while/for/if/
Read in Unknown purpose input while (std::cin >> value), encountered file terminator or invalid input, IStream object invalid, condition failed
Input file Terminator: Ctrl + D (Linux)
[C++primer] [01] Quick Start