摘要:
容器的iterator类型vector::iterator iter;迭代器是一种检查容器内元素并遍历元素的数据类型。begin和end操作vector vec;vector::iterator iter = vec.begin(); //若vec不为空,则iter指向ive... 阅读全文
摘要:
数组数组是类似于vector的低级复合类型。现代C++程序应尽量使用vector类型,只有强调速度时才使用数组。动态数组创建T *pt = new T[size];多维数组int ia[3][4] = { {0,1,2,3}, {4,5,6,7}, {8,9,10,... 阅读全文
摘要:
声明与定义声音与定义的区别在于,声明没有给变量分配空间,而定义则给变量分配了空间;定义也是声明。extern int i; // 声明但未定义int i ; //声明且定义extern double PI = 3.14; //声明且定义文件用于声明而不是定义。之所以这样的原因是有时... 阅读全文
摘要:
标准库string类型string对象初始化string s1;string s2(s1);string s3("value");string s4(n,'c');string对象的读写string s;cin>>s; //读取并忽略开头的所有... 阅读全文