c++第五次上机实验第二题
来源:互联网 发布:战舰世界mac版国服 编辑:程序博客网 时间:2024/05/21 12:49
#include<iostream>
#include<string>
using namespace std;
class Person
{
string name;
int age;
string sex;
public:
Person() {}
void setname(string na)
{
name=na;
}
void setage(int a)
{
age=a;
}
string getname()
{
return name;
}
int getage()
{
return age;
}
void setsex(string a)
{
sex=a;
}
string getsex()
{
return sex;
}
};
class Teacher: virtual public Person
{
string title;
public:
void settitle(string a)
{
title=a;
}
string gettitle()
{
return title;
}
};
class Cadre:virtual public Person
{
string post;
public:
void setpost(string pt)
{
post=pt;
}
string getpost()
{
return post;
}
};
class Teacher_Cadre: public Teacher,public Cadre
{
int waves;
public:
void setwaves(int a)
{
waves=a;
}
int getwaves()
{
return waves;
}
};
int main()
{
Teacher_Cadre c;
c.setname("曾辉");
c.setage(42);
c.setsex("男");
c.setpost("副教授");
c.setwaves(1540);
cout<<c.getname()<<endl<<c.getage()<<endl<<c.getsex()<<endl<<c.getpost()<<endl<<c.getwaves()<<endl;
return 0;
}
#include<string>
using namespace std;
class Person
{
string name;
int age;
string sex;
public:
Person() {}
void setname(string na)
{
name=na;
}
void setage(int a)
{
age=a;
}
string getname()
{
return name;
}
int getage()
{
return age;
}
void setsex(string a)
{
sex=a;
}
string getsex()
{
return sex;
}
};
class Teacher: virtual public Person
{
string title;
public:
void settitle(string a)
{
title=a;
}
string gettitle()
{
return title;
}
};
class Cadre:virtual public Person
{
string post;
public:
void setpost(string pt)
{
post=pt;
}
string getpost()
{
return post;
}
};
class Teacher_Cadre: public Teacher,public Cadre
{
int waves;
public:
void setwaves(int a)
{
waves=a;
}
int getwaves()
{
return waves;
}
};
int main()
{
Teacher_Cadre c;
c.setname("曾辉");
c.setage(42);
c.setsex("男");
c.setpost("副教授");
c.setwaves(1540);
cout<<c.getname()<<endl<<c.getage()<<endl<<c.getsex()<<endl<<c.getpost()<<endl<<c.getwaves()<<endl;
return 0;
}
0 0
- c++第五次上机实验第二题
- 第五次C语言上机实验报告
- 第五次C语言上机实验报告
- C语言第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- 第五次上机实验
- codeforces 670C Cinema
- 2、Ajax与Java通过POST方式交互
- 欢迎使用CSDN-markdown编辑器
- Shader之学习笔记四
- 数据存储(3)自定义内容提供器
- c++第五次上机实验第二题
- sql常用命令
- fragment及fragment的通信
- c++第5次实验
- 18大经典数据挖掘算法小结
- oracle补丁p18841764相关
- 让UITableView的表头随着tableView一起滚动
- iOS滑动解锁/滑动获取验证码效果实现
- Spring MVC控制层判断登录 ,登录失败则返回提示信息