//Cadre.h
#pragma once
class Cadre
{
public:
Cadre(char*,int,int,char*,char*,char*);
~Cadre();
void display();
void getpost();
private:
int age;
int sex;
char add[50];
char tel[20];
public:
char name[20];
char post[20];
};
//Teacher.h
#pragma once
class Teacher
{
public:
Teacher(char*,int,int,char*,char*,char*);
~Teacher();
void display();
private:
int age;
int sex;
char add[50];
char tel[20];
public:
char name[20];
char title[20];
};
//Teacher-Cadre.h
#pragma once
#include "Teacher.h"
#include "Cadre.h"
#include<iostream>
class Teacher_Cadre :public Teacher,public Cadre
{public:
Teacher_Cadre(char*Nam, int a, int s, char*add, char*tel, char*tit, char *pos, double wages);
~Teacher_Cadre();
void show();
private :
double wages;
};
//Cadre.cpp
#define _CRT_SECURE_NO_WARNINGS
#include "Cadre.h"
#include<iostream>
using namespace std;
Cadre::Cadre(char *Nam, int a, int s, char *add, char *tel, char *pos)
{
strcpy(name , Nam);
age = a;
sex = s;
strcpy(this->add , add);
strcpy(this->tel, tel);
strcpy(post ,pos);
}
Cadre::~Cadre()
{
cout << "Cadre析构函数" << endl;
}
void Cadre::display()
{
cout << "name:" << name << "\n" << "age:" << age << "\n" << "address:" << add << "\n" << "telephoto:" << tel << "\n" << "post:" << post << "\n";
}
void Cadre::getpost()
{
cout<<post;
}
//Teacher.cpp
#define _CRT_SECURE_NO_WARNINGS
#include "Teacher.h"
#include<iostream>
using namespace std;
Teacher::Teacher(char*Nam, int a, int s, char*add, char*tel, char*tit)
{
strcpy(name, Nam);
age = a;
sex = s;
strcpy(this->add, add);
strcpy(this->tel, tel);
strcpy(title, tit);
}
Teacher::~Teacher()
{
cout << "Teacher析构函数" << endl;
}
void Teacher::display()
{
cout << "name:" << name << "\n"<< "age:" << age << "\n" << "address:" << add << "\n" << "telephoto:" << tel << "\n" << "title:" << title << "\n" ;
}
//Teacher-Cadre.cpp
#include "Teacher_Cadre.h"
#include "Teacher.h"
#include "Cadre.h"
#include<iostream>
using namespace std;
Teacher_Cadre::Teacher_Cadre(char*Nam, int a, int s, char*add, char*tel, char*tit, char *pos, double w) : Teacher(Nam, a, s, add, tel, tit), Cadre(Nam, a, s, add, tel,pos)
{
wages = w;
}
Teacher_Cadre::~Teacher_Cadre()
{
cout << "Teache_Cadre" << endl;
}
void Teacher_Cadre::show()
{
Teacher::display();
cout <<Cadre::name<<"\n"<< "post:" << post << "\n" << "wages:" << wages << endl;
}
//main.cpp
#include "Teacher.h"
#include "Cadre.h"
#include "Teacher_Cadre.h"
#include<iostream>
using namespace std;
int main()
{
Teacher_Cadre a1("liming",20,0, "http//www,dddd","0556-123456789","professor","leader",10000);
a1.show();
system("pause");
return 0;
}