I'm going to take a good look again today. C + + Primer This very classic book, The Notes begin:
1. Each C + + program contains one or more functions, which must have a main, the operating system by calling main to start running the program;
2. Functions include: return type, function name, line parameter list, function body. The return type of the main function must be an int integer type. In a general system, the return value of main is used to indicate the state, and a return value of 0 indicates success, not 0 defined by the system;
3. Input/Output (IO): The iostream library in the standard library (STD) contains two base types IStream and Ostream, respectively, the input stream and the output stream, and a stream is a sequence of characters that is read from or written to the IO device,
STD defines 4 IO objects, IStream cin, called standard input, ostream cout, called standard output, ostream ceer and clog, usually ceer to output warnings and error messages, clog to output general information;
4.cout and CIN are output left operand, so a sentence cout<<v1<<v2 is equivalent to two sentences cout<<v1;cout<<v2; and the same CIN can be;
5.<< output operator,>> input operator,:: scope operator,//sentence specifier,/* Multi-statement Program statements */Comment a paragraph, in addition: =,==,!=,<=,>=,<,>,++,--;
Below is a small program to cover the above small knowledge points:
//read the variable number of input data for processing;//the while will loop until a file terminator is encountered, and Windows Terminator is ctrl+z,linux to Ctrl+d;#include<iostream>//header Fileusing namespaceStd//with Std::cout a function;intMain () {intsum =0; intval =0; while(cin>>val) {Sum= Sum+val;//same sum + = val;} cout<<"sum ="<<sum<<Endl; System ("Pause");//causes the System window to pause the command, if does not add to see cout result, with OpenCV in Waitkey; return 0;}
C + + Primer Note (1) fighter input and output data processing in the foundation