I. string # include <string> using std: string initialization function: string s1; the default constructor s1 is an empty string s2 (s1 ); initialize s2 to a copy of s1 string s3 ("value"); initialize s3 to a copy of string Literal value string s4 (n, 'C '); initialize s4 into n copies of the character 'C' string s4 (5, '6') 66666 to be compatible with the c language, the string literal value is not of the same type as the string type in the standard library. Cin> s; read string from standard input and store the read string in s. String type input OPERATOR: • Read and ignore all leading blank characters (such as spaces, line breaks, and tabs ). • Read the character until it encounters a blank character again, and the read ends. Read string str; while (cin> str) {cout <str <endl ;} use getline to read the main line text string line; while (getline (cin, line) {cout <line <endl;} string operator s. empty () If s is an empty string, true is returned; otherwise, false is returned. S. size () returns the number of characters in s. Return type: string: size_type. S [n] returns the characters whose position is n in s. The position starts from 0 and s1 + s2 is counted. s1 and s2 are connected into a new string, returns the newly generated string s1 = s2. replaces the s1 content with the s2 copy v1 = v2 to compare the content of v1 and v2. If it is equal, true is returned. Otherwise, false is returned! =, <, <=,>, And> maintain the meanings of these operators # include <CCType. h> In cctype, function compute has been scaled into isalnum (c) isalpha (c) iscntrl (c) isdigit (c) isgraph (c) islower (c) isprint (c) ispunct (c) isspace (c) isupper (c) isxdigit (c) tolower (c) toupper (c) True if c is a letter or number. True if c is a letter. True if c is a control character. true if c is a number. True if c is not a space but printable. True if c is a lowercase letter. True if c is a printable character. True if c is a punctuation mark. True if c is a blank character. True if c is an uppercase letter. True if it is a hexadecimal number of c. If c is an upper-case letter, return the lower-case letter; otherwise, return c directly. If c is a lowercase letter, it is returned in the uppercase letter format. Otherwise, c is returned directly. We recommend that you renew your subscription when necessary. please refer to the following link for more information: the C ++ version of the C standard library header file is used, # include <cctype> C this version is recommended # include <ctype. h> C ++ ----------------------------------------------------- 2. vector is a collection of the same type of objects # include <vector> using std: vector; vector <int> ivec; // vector is not a data type, but a type template, vector <int> is a data type that initializes vector <T> v1. The storage type of vector is T object. The default constructor v1 is null. Vector <T> v2 (v1); IKEv2 is a copy of v1. Vector <T> v3 (n, I); Limit v3 contains n elements whose values are I. Struct vector <T> v4 (n); vector <int> v4 (10); struct v4 contains n copies of elements whose values are initialized. 10 elements, each initialized to 0 the vector Standard Library provides many operations similar to the string object v. empty () If v is null, true is returned; otherwise, false is returned. Optional v. size () returns the number of elements in v. Vector <int>: size_type num; then v. push_back (t) adds an element with the value t at the end of v. V [n] returns the element whose position is n in v. V1 = v2 then replace the v1 element with a copy of the element in v2. V1 = v2 If v1 and v2 are equal, true is returned. Too many! =, <, <=,>, And> = operators maintain the meanings of these operators: secure generic programming C ++ programmers who are used to C or Java programming may find it hard to understand and use the for loop judgment conditions! = Instead of using <to test whether the scalar value of the vector is out of the border. What the C programmer cannot understand is that in the previous example, the size member function is not called before the for loop and the returned value is saved. Instead, the size member function is called in the for statement header. C ++ programmers are used to choosing first! = Instead of <. In the above example, there is no special reason to choose or not use a certain operator. After learning generic programming in the second part of this book, you will understand the rationality of this habit. Calling the size member function without saving the value returned by it is also not required in this example, but this reflects a good programming habit. In C ++, some data structures (such as vector) can grow dynamically. In the previous example, the loop only needs to read elements without adding new elements. However, the loop can easily add new elements. If new elements are added, testing the saved size value as the end condition of the Loop will cause problems, because the new elements are not included. Therefore, we tend to test the current size value in each loop, instead of storing the copy of the size value before entering the loop. In chapter 7, we will learn that some functions in C ++ can be declared as inline functions. When the compiler encounters an inline function, it will directly expand the corresponding code, rather than calling the actual function. Small library functions such as size are almost all defined as inline functions, so the price for calling them during each cycle is relatively small. Each container type defines its own iterator type, which is used to access elements in the container. That is, each container defines its own iterator such as vector: vector <int> :: iterator iter; 1. begin ()/end () for (vector <int>: iterator iter = text. begin (); iter! = Text. end (); iter ++) {* iter = 4;} can only read elements in the container, but cannot change vector <int >:: const_iterator 2. arithmetic Operation iter + n; iter1-iter2 defference_type 3. bitset # include <bitset> using std: bitset; initialize bitset <n> B; // B has n bits, each of which has 0 bitset <32> B;  bitset <n> B (u); // B is a copy of the unsigned long u bitset <32> B (0 xffff); // bits 0... 15 are set to 1, 16... 31 are 0 bitset <n> B (s); // B is a copy of the bits contained in string object s string strval ("1 100 "); bitset <32> bitvec4 (strval); // the order in which the bitset is read from the string object is from right to left ): in bitvec4 bit mode, the positions 2nd and 3 are 1, and the remaining positions are 0. If the number of characters in the string object is smaller than the length of the bitset type, the higher order is 0.  Bitset <n> B (s, pos, n); // starting from position pos in s & nbps; secondary string str ("1111111000000011001101") of n digits; bitset <32> bitvec5 (str, 5, 4); // 4 bits starting at str [5], 1100-bit operation B. is there any () B binary bit set to 1? Isn't the binary bit set to 1 in bytes B. none () B? Please wait until then before B. the number of binary bits in count () B that are set to 1 is less than bytes less than B. size () the number of binary bits in B is too large to access B [pos]. The binary bits in B are too large to access B. is the binary position of test (pos) B at pos 1? Please wait until then before B. set () sets all binary bits in B to 1 bytes B. reset () sets all binary bits to 0 bytes B. set (pos) sets the binary position of B at the pos position to 1 flip. The bitset object can be reversed to all or individual bits: bitvec. flip (0); // reverses value of first bit bitvec [0]. flip (); // also reverses the first bit bitvec. flip (); // reverses value of all bits