第五章t10
来源:互联网 发布:北上广深经济数据对比 编辑:程序博客网 时间:2024/04/30 13:48
#include <iostream>#include <cstring>using namespace std;class Teacher {public: Teacher(int,char [],char); void display(); private: int num; char name[20]; char sex; };Teacher::Teacher(int n,char nam[],char s) {num=n; strcpy(name,nam); sex=s;}void Teacher::display() {cout<<"num:"<<num<<endl; cout<<"name:"<<name<<endl; cout<<"sex:"<<sex<<endl;}class BirthDate {public: BirthDate(int,int,int); void display(); void change(int,int,int); private: int year; int month; int day;};BirthDate::BirthDate(int y,int m,int d) {year=y; month=m; day=d; }void BirthDate::display() {cout<<"birthday:"<<month<<"/"<<day<<"/"<<year<<endl;}void BirthDate::change(int y,int m,int d) {year=y; month=m; day=d; }class Professor:public Teacher {public: Professor(int,char [],char,int,int,int,float); void display(); void change(int,int,int); private: float area; BirthDate birthday; };Professor::Professor(int n,char nam[20],char s,int y,int m,int d,float a): Teacher(n,nam,s),birthday(y,m,d),area(a){ } void Professor::display() {Teacher::display(); birthday.display(); cout<<"area:"<<area<<endl;}void Professor::change(int y,int m,int d) {birthday.change(y,m,d); }int main(){Professor prof1(3055,"li",'m',1933,05,01,150.9); cout<<endl<<"original data:"<<endl; prof1.display(); cout<<endl<<"new data:"<<endl; prof1.change(1950,6,1); prof1.display(); return 0;}
0 0
- 第五章t10
- 第五章T10
- 第三章T10
- sony t10
- t10-6
- T10 DIF
- 小鸡腿U T10 Tokyo2014
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- mark-fragment中获取控件的时机
- 第五章t9
- 设计模式
- Hadoop学习笔记(八)---内置数据类型与自定义数据类型
- 秦淮八艳
- 第五章t10
- 正确使用std::auto_ptr
- Project Euler:Problem 25 1000-digit Fibonacci number
- 华为OJ之初级篇Ⅲ
- 学习ASP.NET MVC5框架揭秘笔记-ASP.NET MVC路由(三)
- hdu2066一个人的旅行——最短路(多起点,多终点)
- 判断IOS判断以便进行适配
- 垂直和水平极化图
- Android崩溃日志记录