现代c++尽量使用vector(容器)和迭代器(相当于指针),少使用数组和指针,除非对程序执行效率有很高的要求。
容器优点,易于扩展,可通过push_back方法动态添加元素,数组不能动态添加元素。
用法:
例:
vector<int> a;
for(vertor<int>::iterator ita = a.begin(); ita != a.end(); ita++)
{
*ita = 0;
}