⑴ 继承与派生 C++的问题
基类:高校人员
学生 和教师 继承 高校人员
(既是学生又是教师 多重继承 学生和教师) (教授继承教师)
总共是3个层次
下面是我写的总共是一个test.h头文件一个 源文件
VS2005编译器下通过 没有任何错误和警告...
如果楼主需要 VC6.0版本的代码 我可以帮忙稍微改整下.
另外 由于时间匆忙 文档就没写 如果楼主看着吃力的话 我有空再加上文档
*****************************test.h*********
#ifndef _iostream_
#define _iostream_
#include <iostream>
#endif
#include <string>
using std::string;
using std::cin;
using std::cout;
using std::endl;
class Person
{
private:
string name;
int age;
public:
Person()// 默认初始化
{
}
Person(const string name,const int age)//带参数初始化
{
this->name=name;
this->age=age;
}
Person(const Person & a)//拷贝构造函数
{
name=a.name;
age=a.age;
}
Person & operator =(Person & a)//赋值运算符重载
{
name=a.name;
age=a.age;
return a;
}
void init_name()
{
cout<<"请输入姓名"<<endl;
cin>>name;
}
void init_age()
{
cout<<"请输入年龄"<<endl;
if(!(cin>>age))
{
cout<<"输入数据过大"<<endl;
exit(0);
}
cin.ignore(1024,'\n');
}
void show_name()
{
cout<<"name: "<<name<<endl;
}
void show_age()
{
cout<<"age: "<<age<<endl;
}
virtual void init()
{
init_name();
init_age();
}
virtual void show()
{
show_name();
show_age();
}
virtual void showface()=0;
bool search(const string str)
{
return (str==name);
}
};
class Student:public Person
{
private:
string speciality;
public:
Student():Person()
{
}
Student(const string name,const int age,const string speciality):Person(name,age)
{
this->speciality=speciality;
}
Student(const Student & a):Person(a)
{
speciality=a.speciality;
}
Student & operator =(Student & a)
{
Person::operator =(a);
speciality=a.speciality;
return a;
}
void init_speciality()
{
cout<<"请输入专业"<<endl;
cin>>speciality;
}
void show_speciality()
{
cout<<"speciality: "<<speciality<<endl;
}
void init()
{
Person::init();
init_speciality();
}
void show()
{
Person::show();
show_speciality();
}
void showface()
{
cout<<"这是一个学生"<<endl;
}
};
class Teacher:public Person
{
private:
string str_department;
public:
Teacher():Person()
{
}
Teacher(const string name,const int age,const string str):Person(name,age)
{
str_department=str;
}
Teacher(const Teacher & t):Person(t)
{
str_department=t.str_department;
}
Teacher& operator =(Teacher & t)
{
Person::operator =(t);
str_department=t.str_department;
return t;
}
void init_str_department()
{
cout<<"请输入所在系"<<endl;
cin>>str_department;
}
void show_str_department()
{
cout<<"department: "<<str_department<<endl;
}
void init()
{
Person::init();
init_str_department();
}
void show()
{
Person::show();
show_str_department();
}
void showface()
{
cout<<"这是一个教师"<<endl;
}
};
class ST:virtual public Student,virtual public Teacher
{
public:
ST():Student(),Teacher()
{
}
ST(const string name,const int age,const string speciality,const string str):Student(name,age,speciality),Teacher(name,age,str)
{
}
ST(const ST & st):Student(st),Teacher(st)
{
}
ST & operator =(ST &st)
{
Student::operator =(st);
Teacher::operator =(st);
}
void init()
{
Person::init_name();
Person::init_age();
init_speciality();
init_str_department();
}
void show()
{
Student::show();
show_str_department();
}
void showface()
{
cout<<"这个既是学生又是老师"<<endl;
}
bool search(const string str)
{
return (Student::search(str));
}
};
class Professor:public Teacher
{
private:
string str_level;
public:
Professor():Teacher()
{
}
Professor(const string name,const int age,const string str1,const string str2):Teacher(name,age,str1)
{
str_level=str2;
}
Professor(const Professor & p):Teacher(p)
{
str_level=p.str_level;
}
Professor& operator =(Professor & pro)
{
Teacher::operator =(pro);
str_level=pro.str_level;
}
void init_str_level()
{
cout<<"请输入教授的级别"<<endl;
cin>>str_level;
}
void show_str_level()
{
cout<<"professor: "<<str_level<<endl;
}
void init()
{
Teacher::init();
init_str_level();
}
void show()
{
Teacher::show();
show_str_level();
}
void showface()
{
cout<<"这是一个教授"<<endl;
}
};
****************************************test.cpp***************************
// TEST.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include "test.h"
using namespace std;
#define M 1
int _tmain(int argc, _TCHAR* argv[])
{
Student stu[M];
Teacher tea[M];
ST st[M];
Professor pro[M];
//********************************************************读取数据**************************************
cout<<"请输入"<<M<<"个学生的数据"<<endl;
for(int i=0;i!=M;i++)
{
stu[i].init();
}
cout<<"请输入"<<M<<"个教师的数据"<<endl;
for(int i=0;i!=M;i++)
{
tea[i].init();
}
cout<<"请输入"<<M<<"个既是学生又是老师的数据"<<endl;
for(int i=0;i!=M;i++)
{
st[i].init();
}
cout<<"请输入"<<M<<"个教授的数据"<<endl;
for(int i=0;i!=M;i++)
{
pro[i].init();
}
//*********************************************************************************
while(1)
{
bool check=false;
cout<<"请输入要查询的名字,输入exit退出"<<endl;
string str;
cin>>str;
if(str=="exit")
break;
for(int i=0;i!=M;i++)
{
if(stu[i].search(str))
{
stu[i].showface();
stu[i].show();
cout<<endl<<endl<<endl;
check=true;
}
if(tea[i].search(str))
{
tea[i].showface();
tea[i].show();
cout<<endl<<endl<<endl;
check=true;
}
if(st[i].search(str))
{
st[i].showface();
st[i].show();
cout<<endl<<endl<<endl;
check=true;
}
if(pro[i].search(str))
{
pro[i].showface();
pro[i].show();
cout<<endl<<endl<<endl;
check=true;
}
}
if(!check)
{
cout<<"无此人的档案"<<endl;
}
}
return 0;
}
⑵ 继承高校里的楚泽是谁演的
继承高校 电影
7.3分
地区: 中国大陆
全球首映: 2017-1-1
语言: 国语
大陆上映: 暂无
片长: 63 分钟
类型: 剧情 / 青春导
曲晓清代替大她七岁、长得一摸一样的姐姐进皇家学院当班导,遇到了一群特别调皮的富二代学生。好不容易以姐姐的身份混进了学校,却遭到了特别班学生百般刁难和恶整,其中以富二代楚泽为首的恶魔男团与曲晓清各种敌对。但在曲晓清坚持不懈的努力以及富二代少爷韩玉笙的帮助下,这群混混逐渐被曲晓清的行为打动,不由自主的喜欢上了这个“女老师”。面对两个男生的追求,一个和蔼可亲温柔善良,一个冷酷霸道高傲冷漠,她会如何选择?她的真实身份该怎样揭晓