c++primer chapter one

  Definition of a function consists of four parts: the return type (return type), the name of the function (function name), a parameter list containing shaped bracket (parameter, allowing empty) and the function body (function body).

  Source file naming convention: Whether using the command line interface or IDE, most compilers are required to program source code stored in one or more files. Program files are commonly called the source file (source file). In most systems, the name of the source file with a suffix ending, then a suffix is ​​made after only one period or more characters. This suffix tells the system file is a C ++ program. Different compilers use a different suffix naming conventions, the most common include .cc, .cxx, .cpp, .cp and .C.

  C ++ language does not define any input-output (IO) statement, instead, contains a comprehensive standard library (standard library) to provide IO mechanism.

  iostream library contains two basic types istream and ostream, respectively represent input and output streams. A stream is a sequence of characters, a read or write from the IO device IO device. I want to express the term "stream" (Stream) is, over time, the character sequence is generated or consumed.

  All standard library names are defined in the namespace (namespace) std in. std :: cout, by using scope resolution operator (: :) to indicate we want to use the name cout is defined in the namespace std.

  A variable number of input data read

 1 #include <iostream>
 2 
 3 
 4 int main(){
 5     int sum = 0;
 6     int value = 0;
 7     while (std::cin >> value){
 8         sum += value;
 9     }
10     std::cout << "sum is" << sum << std::endl;
11     return 0;
12 }
A variable number of input data read

  

 

Guess you like

Origin www.cnblogs.com/cainiao0002/p/10962399.html