////////////////////////////////////////
// 2018/04/16 15:46:02
// vector-front
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
using namespace std;
template<class T, class D>
class Member
{
private:
T name;
D sal;
public:
Member(T t, D d) :name(t), sal(d){}
void print();
};
template<class T, class D>
void Member<T,D>::print(){
cout << name << " " << sal << endl;
}
// ========================
int main(){
typedef Member<string, double> M;
vector<M> v;
v.push_back(M("Linda", 75000));
v.push_back(M("Robert",60000));
vector<M>::iterator it = v.begin();
cout << "Entir vector:" << endl;
while (it != v.end()){
(it++)->print();
}
cout << endl;
cout << "return from front()" << endl;
v.front().print();
return 0;
}
/*
OUTPUT:
Entir vector:
Linda 75000
Robert 60000
return from front()
Linda 75000
*/
vector-front
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:vector-front
下一篇:vector-insert
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
「从ES到CK 05」clickhouse高效数据处理工具vector
替代logstash的神器:高效的数据处理工具vector
数据处理 clickhouse vector logstash 日志平台 -
vector容器 begin()与end()函数、front()与back()的用法
向量容器(vector)是一种顺序容器
begin end函数 front back 数组 -
deque-pop_front
//////////////////////...
#include ios i++