阅读程序6
2016-06-05 17:51
302 查看
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:zwj.cpp
*作 者:李落才
*完成日期:2016年6月5日
*版 本 号:v1.0
*
*问题描述:阅读程序,对照运行结果,领会STL的用法
*输入描述:
*程序输出:
*/
#include <string>
#include <iostream>
#include <map>
using namespace std;
class CStudent
{
public :
int nStudentID;
int nAge;
public :
CStudent() { }
CStudent(int nSID, int nA)
{
nStudentID=nSID;
nAge=nA;
}
//复制构造函数
CStudent(const CStudent& ob)
{
nStudentID=ob.nStudentID;
nAge=ob.nAge;
}
};
int main()
{
map <string, CStudent> mapStudent;
mapStudent["zhangsan"] = CStudent(100012, 22);
mapStudent["Lisi"] = CStudent(100085, 21);
mapStudent["Wangwu"] = CStudent(100093, 23);
cout << "The Student number for Lisi is " <<(mapStudent["Lisi"].nStudentID) << endl;
return 0;
}
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:zwj.cpp
*作 者:李落才
*完成日期:2016年6月5日
*版 本 号:v1.0
*
*问题描述:阅读程序,对照运行结果,领会STL的用法
*输入描述:
*程序输出:
*/
#include <string>
#include <iostream>
#include <map>
using namespace std;
class CStudent
{
public :
int nStudentID;
int nAge;
public :
CStudent() { }
CStudent(int nSID, int nA)
{
nStudentID=nSID;
nAge=nA;
}
//复制构造函数
CStudent(const CStudent& ob)
{
nStudentID=ob.nStudentID;
nAge=ob.nAge;
}
};
int main()
{
map <string, CStudent> mapStudent;
mapStudent["zhangsan"] = CStudent(100012, 22);
mapStudent["Lisi"] = CStudent(100085, 21);
mapStudent["Wangwu"] = CStudent(100093, 23);
cout << "The Student number for Lisi is " <<(mapStudent["Lisi"].nStudentID) << endl;
return 0;
}
相关文章推荐
- 每天15min-HTML5(3)-文本标签
- Bootsrap字体图标使用
- vmware下centos6 安装jdk1.7
- sql语句查询,分批显示查询结果
- redis使用
- 使用iframe引入百度地图显示企业位置
- Boost.lockfree总结
- hangfire+bootstrap ace 模板实现后台任务管理平台
- [从头读历史] 第244节 三皇与五帝
- BZOJ 4568 幸运数字
- 阅读程序5
- 立体类族共有的抽象类
- 学习进度第十四周
- 一天一个shell命令 linux文本内容操作系列-awk命令详解
- 第七次上机实验
- python map(),reduce()函数的使用
- 个人最终总结
- 阅读程序4
- owin中间件
- 第4章:计算机工业的生态链