第4章 第7题
来源:互联网 发布:剑三军爷男神捏脸数据 编辑:程序博客网 时间:2024/05/14 17:53
#include<iostream>#include<iomanip>#include<string>using namespace std;class Teacher;class Student{private:int num;string name;string sex;string position;public:Student(){};Student(int n,string a,string s,string p):num(n),name(a),sex(s),position(p){}friend Teacher;};class Teacher{public:void display(Student &);Teacher(){}Teacher(int n,string a,string s,string p):num(n),name(a),sex(s),position(p){}private:int num;string name;string sex;string position;};void Teacher::display(Student &s){num=s.num;name=s.name;sex=s.sex;position="Teacher";cout<<"留校后,该学生的信息被转换为:"<<endl;cout<<setw(4)<<"num"<<setw(10)<<"name"<<setw(6)<<"sex"<<setw(10)<<"position"<<endl;cout<<setw(4)<<num<<setw(10)<<name<<setw(6)<<sex<<setw(10)<<position<<endl;} int main(){Student stu[2]={Student(1023,"Liu","male","Student"),Student(1045,"Chen","male","Student")};Teacher t1;for(int i=0; i<2; i++)t1.display(stu[i] );return 0;}
0 0
- 第4章 第7题
- 第7章第4题
- 第7章 第4题
- 第4章 第4题
- 第1章 第7题
- 第3章 第7题
- 第7章 第1题
- 第7章第1题
- 第7章第2题
- 第7章第3题
- 第7章 第2题
- 第7章 第3题
- 第7章 第5题
- 第7章 第6题
- 第7章第5题
- 第7章第6题
- 第10章第7题
- 第2章第4题
- Qt学习
- IOS 如何选择delegate、notification、KVO?
- 模板方法和接口参数的联合使用
- [CF538F]A Heap of Heaps && 持久化线段树
- 第四章第5题
- 第4章 第7题
- 2.1 各种标签
- CACTI :Required modules for PHP Weathermap 0.97c were not present. Not running
- 编程之美2.17—数组循环移位(旋转数组)
- Linux串口驱动分析初始化
- getBaseContext(),getApplication(),getApplicationContext()
- 市赛回顾
- linux实现shell命令支持ipv4地址转换
- 进程与线程的一个简单解释