#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include "vector"
#include "algorithm"
//异常的栈解旋
using namespace std;
class teacher{
public :
int a;
public :
teacher(int a){
this->a=a;
}
};
int main1(){
teacher t1(25),t2(26),t3(27);
teacher *p1,*p2,*p3;
p1=&t1;
p2=&t2;
p3=&t3;
vector<teacher *> v1;
v1.push_back(p1);
v1.push_back(p2);
v1.push_back(p3);
for(vector<teacher *>::iterator it=v1.begin();it!=v1.end();it++){
cout<<(*it)->a<<endl;
}
vector<teacher> v2;
bool isempty=v2.empty();//判断是否为空
if(isempty) {
cout<<"为空"<<endl;
}
}
int main0(){
teacher t1(25),t2(26),t3(27);
vector<teacher> v1;
v1.push_back(t1);
v1.push_back(t2);
v1.push_back(t3);//v1.begin返回的是迭代器
for(vector<teacher>::iterator it=v1.begin();it!=v1.end();it++){
cout<<it->a<<endl; //本身就是引用了不用*
}
}
int main(){
vector<int> v1;
v1.push_back(1);
v1.push_back(2);
v1.push_back(3);
for(vector<int>::iterator it=v1.begin();it!=v1.end();it++){
cout<<*it<<endl; //取得引用
}
v1.pop_back(); //删除末尾元素,最后末尾是三,但结果是0!
for(vector<int>::iterator it=v1.begin();it!=v1.end();it++){
cout<<*it<<endl; //取得引用
}
v1.clear(); //删除所有元素
for(vector<int>::iterator it=v1.begin();it!=v1.end();it++){
cout<<*it<<endl; //取得引用
}
int num=count(v1.begin(),v1.end(),3);
cout<<num<<endl;
}