源程序如下,能帮我找下错误吗
#include<iostream>
#include<vector>
using namespace std;
class A
{
public:
int a;
A(int aa){a=aa;}
void print(){cout<<a<<endl;}
};
int main()
{
vector<A> v;
vector<A>::iterator p=v.begin();
A aaa(4);
A bb(6);
v.push_back(aaa);
v.push_back(aaa);
v.push_back(aaa);
v.push_back(aaa);
p++;
p++;
v.insert(p,bb);
for(int i=0;i<5;i++)
v[i].print();
}
能加上vector的各个函数用法的详细解释的话更好,感激不尽!
狐的传说
相关分类