第四单元老师学生类(zuoye)
来源:互联网 发布:一个程序员眼中的fenng 编辑:程序博客网 时间:2024/05/01 19:31
#include<iostream>#include<string>using namespace std;class student; class teacher{private:string name;string id;public:teacher (string a,string b){name=a;id=b;}void teacher_decide(student* p);void show1(){cout<<name<<" "<<id<<endl;}};class student{private:string name;string id;double math;double chinese;public:student(string a,string b){ name=a; id=b;}friend void teacher::teacher_decide(student* p);void show(){cout<<"name:"<<name<<" "<<"id:"<<id<<" "<<" math:"<<math<<" "<<"chinese:"<<chinese<<"\n";}}; void teacher::teacher_decide(student* p) { for(int i=0;i<4;i++,p++){cout<<"please input math's score:"<<endl;int m=0,n=0; cin>>m;p->math=m; cout<<"please input chinese's score:\n"; cin>>n;p->chinese=n;cout<<endl;} }int main(){teacher teacher1("mingge","zhanjian");student student1[4]={student("huangchongwen","xingning"),student("linroqin","huizhuo"),student("chenxi","shangtuo"),student("dazhong","zhuohai")}; student* q=student1; teacher1.teacher_decide (q); for(int j=0;j<4;j++) { student1[j].show(); } teacher1.show1 (); return 0;}
0 0
- 第四单元老师学生类(zuoye)
- 学生 老师 类
- 学生老师类
- zuoye
- zuoye
- ZUOYE
- zuoye
- zuoye
- zuoye
- zuoye
- zuoye
- zuoye
- zuoye
- ZUOYE
- zuoye
- zuoye
- zuoye
- Zuoye
- 第六周项目6-2:复数模版类
- Kakuro Extension (hdu 3338 最大流 建图难)
- 时间复杂度和空间复杂度 2
- vim 配置
- DICOM:DICOM Print 服务详细介绍
- 第四单元老师学生类(zuoye)
- 动态规划:从新手到专家
- 2015/4/19
- 欢迎使用CSDN-markdown编辑器
- (二十七)unity4.6学习Ugui中文文档-------Unity3D UI (uGUI)窗口扩展
- PHP计划任务:如何使用Linux的Crontab执行PHP脚本
- 2015年3-4月 同事面试题目汇总
- 存储过程的优缺点
- Apache2不能启动的解决办法(提示could not bind to address 0.0.0.0:80)