chapter_03
Tags
字符串向量和数组
namespace using declarations
Don’t use using declaration in header files:header files will be included in different files which don’t intend to use the specified library name, then it might encounter unexpected name confilicts
library types not only provide us with specify operations, but it shows good efficiency which is enough for general use
size_type type: one of companion type defined by string
the comparation of string
- the longer is big
- it is ulp to the first differ digit
input
>> : begin with the first charactor which is not whitespace(e.g spaces, newline, tab), end with whitepace
getline(): get the line whatever it contains
some functions about the character in the string
some functions to get the nature of specific chacracter in the string on page 92
range for statement
- for(auto c : str)
- for(auto &c : str)、decltype(str.size()) n = 0;
vector
initializaton
add elements
iterator
array
the difference between array and vector
- vector can copy entirely
- vector doesn’t need to reule the size when decfine, but array need
- vector can increse itselt at run time, but array can’t
- the subscripts of an array is not unsigned type, so it can be a negative value,but the subscriptsof library types such as string and vector is unsigned
auto p = array; (p is a pointer)but, decltype(array) a = {1, 2 ,1 ,3}; 得到的是一个数组
可以用begin函数和 end 函数获得array 中的迭代器一样的体验
不同的指针之间做比较有一个条件:他们必须在同一个容器内(两个容器要具有相关性)
array compund with “&” and “*”
interpret it from inside out
Loading...