1. Preprocessor indicator
If the file name is enclosed in angle brackets "<" and ">", it means that it is a project or standard header file, and the lookup process examines the predefined directories.
If the file name is enclosed in double quotation marks, it is a user-defined header file that will start from the current file directory when the file is found.
2. The comment block cannot be nested, that is, the following conditions are not allowed
/*
* Do not allow/**/
*/
3. File terminator, use CTRL + Z on Mac using CTRL + D;windows;
—————-2016-07-12 ———————
The input operator of the 4.string object,
(1). Read and ignore whitespace characters (such as spaces, line breaks, tabs) that begin with
(2). Reads the character until it encounters a whitespace character again, and the read terminates.
5. Reads the entire line of text with Getline, and the string returned by Getline does not contain a line break
6.vector--efficient dynamic add-on elements
(1) Definition and initialization
vector<t> v1;//v1 default to Empty vector<t> v2 (v1),//v2 is V1 copy vector<t> v3 (n,i),//v3 contains n elements with value I vector<t> V4 (n);//v4 n copies of elements containing value initialization
(2) Common operation
V.empty ();//Determine if V is an empty v.size ();//Returns the number of elements in V, the return value type is size_typev.push_back (t), or a element with a value of t at the end of V v[n];//returns an element of position N in v. Subscript operation is not allowed to add elements, only the specified elements can be obtained
7. Iterators are used to access elements within a container, each of which defines a type named iterator.
Simple use of iterators:
Std::vector<int>::iterator iter;for (iter = Ivec.begin (); Iter!=ivec.end (); iter++) {cout<<*iter<< Endl;}
You can also change the value of the elements in the vector by using iterators, as follows:
Std::vector<int>::iterator iter;for (iter = Ivec.begin (); Iter!=ivec.end (); iter++) { *iter = 0; Cout<<*iter<<endl;}
In addition to the iterator type, there is also a const_iterator type whose iterator can only access elements within the vector and cannot change the value of its elements.
Std::vector<int>::const_iterator citer;for (citer = Ivec.begin (); citer!= ivec.end (); citer++) { cout< < "DASFJSDFJ" <<*CITER<<ENDL;}
8. Arrays
(1) Non-const constants and const constants that are not known for their values until run time cannot be used to define
The number of dimensions of the array. Such as:
const int value = 3;int ss_size = 30;const int bb_size = GetSize ();d ouble a[ss_size];//errorint b[value];//okint c[bb_size ];//error
(2) An array is not allowed to be initialized with another array, and an array is not allowed to be assigned to another array.
As follows:
int ia[] = {0,1,2};int ia2[] (IA);//errorint Ia3[3];//ok, but elements is Uninitialized!ia3 = Ia;//error
Subsequent updates ...
C + + Learning Foundation One