Chapter 3 vector and array of strings

1, header files should not include using statement

2, direct initialization string (str) or string (num, 'char'); copy initialization: string str = str2;

3, getling (cin, line) until the first read line and a read line break discarded newline

4, if a statement has size () function, do not int to avoid mix

. 5, must be a string type adder string object, consider the sequence of operations when determining whether a plurality of addition method, not a string literal string type

6, string type is larger than the size comparison lowercase uppercase letters, the rearward large order

7, C ++ version of the C standard library header files: cname; eg: math.h: cmath;

8、范围for(range for)  eg: for(auto c: str)

9, if the elements of the variant string for use in:  for (C & Auto: STR); loop variable must be defined as a reference type

10, using the subscript operator must ensure the effectiveness of the subscript

11, vector: unable to perform list after confirming initialization, the compiler will try to initialize a vector defaults

12, vector objects and object string subscript operator can access existing elements, but can not be used to add value

13, accustomed to using == and =, because all containers and defines == =;!! Iterator const_iterator

. 1 4. The three meanings iterator: iterator concept itself; container iterator type defined; an iterator object

15, whenever the container using the loop iterator, iterator does not want to add elements belongs;

16, the iterator iterator operations must be the same container

 17, elements through the array of the best and scope for statement

18, using the array initialization vector: the first address of the array and specified after the end of the address

19, pointers and arrays:

When the array type used as an initial value extrapolated auto variable is a pointer

When the above conversion does not occur decltype keyword

20, built subscript operator used index value is not an unsigned type of vector and string are not the same

21, allows the use of an array of characters in a null-terminated string to initialize the object or objects assigned to string

Allows null terminated character array as one of the operands adder string object (both are not)

It allows the use of compound assignment operators string operations to null terminated character array as the right side of the operands.

22, const char * str = s.c_str (); s subsequent changes the value of the return address may be invalid, a solution, a copy of the array again;

23, use of the for statement processing multi-dimensional arrays, in addition to the innermost loop all the other control variables cycle should be a reference type. Because auto without the use of reference will be declared as a pointer

 

Guess you like

Origin www.cnblogs.com/xiaogaogao/p/11737028.html