#include#include using namespace std; int main() { vector squares(100); for(int i=0;i 该程序创建了一个vector对象,存储100个完全平方数并将它们输出。vector的一个优良特点:容易改变其自身的大小。
数组的初始化
int daysInMonth[]={31,28,31,30,31,30,31,31,30,31,30,31} vectordaysInMonth={31,28,31,30,31,30,31,31,30,31,30,31} vector daysInMonth{31,28,31,30,31,30,31,31,30,31,30,31} vector daysInMonth(12) //初始化大小为12的vector string拥有比较两个字符串状态的所有关系运算符和相等运算符。如果两个字符串str1和str2的值相同,那么str1==str2就是true。此外sring还有一个length方法,可以返回字符串长度。而vector可以使用size方法,返回长度。



