STL初识
vector存放自定义数据类型
存放对象
#include<vector>
#include<string>
class person{
public:
person(string name,int age){
this->mName=name;
this->mage=age;
}
string mName;
int mage;
}
void test01(){
vector<person> v;
person p1("a",10);
person p2("b",20);
person p3("c",30);
v.push_back(p1);
for(vector<person>::iterator it=v.begin(); it!=v.end();it++){
cout<<(it*).mName<<endl;
}
存放对象指针
vector<person*> v;
v.push_back(&p1);
for{
person *p=(*it);
cout<<p->mName<<(*it)->mage;
}