不用迭代器的容器表示
2016-03-09 19:57
211 查看
/*[方式一] 结构体放栈中,vector中放副本---------------------*/ #include <iostream> #include <string> #include <vector> typedef struct student{ char school_name[100]; char gender; int age; bool is_absent; } StudentInfo; typedef std::vector<StudentInfo> StudentInfoVec; void print(StudentInfoVec* stduentinfovec){ for (int j=0;j<(*stduentinfovec).size();j++) { std::cout<< (*stduentinfovec)[j].school_name<<"\t"<< (*stduentinfovec)[j].gender<<"\t"<< (*stduentinfovec)[j].age<<"\t"<< (*stduentinfovec)[j].is_absent<<"\t"<<std::endl; } return; } int main(){ StudentInfo micheal={"Micheal",'m',18,false}; StudentInfo cherry={"Cherry",'f',16,true}; StudentInfoVec studentinfovec; studentinfovec.push_back(micheal); studentinfovec.push_back(cherry); print(&studentinfovec); return 0; }
相关文章推荐
- win7出现无法连接到代理服务器的错误,不能上网的问题的解决
- The Worm Turns
- iOS黑魔法-Method Swizzling
- 作业1
- winform textBox输入提示
- 蓝桥杯--2012--古堡算式(暴力)
- Android适配器详解
- Codeforces 631E:Product Sum
- 第二周项目简短程序
- CSS预处理器Sass(Scss)、Less、Stylus
- 为什么要多线程开发
- 蓝桥杯--2012--古堡算式(暴力)
- bzoj 1367
- Xcode重构功能怎么用我全告诉你
- HDU2519新生晚会(组合数公式)
- 生成前N个自然数的一个随机置换
- js中如何将字符串转化为时间,并计算时间差
- Struts2基础学习总结
- 二维线段树模板题 hdu 4819
- 第二周项目简短程序