⑴ 繼承與派生 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 分鍾
類型: 劇情 / 青春導
曲曉清代替大她七歲、長得一摸一樣的姐姐進皇家學院當班導,遇到了一群特別調皮的富二代學生。好不容易以姐姐的身份混進了學校,卻遭到了特別班學生百般刁難和惡整,其中以富二代楚澤為首的惡魔男團與曲曉清各種敵對。但在曲曉清堅持不懈的努力以及富二代少爺韓玉笙的幫助下,這群混混逐漸被曲曉清的行為打動,不由自主的喜歡上了這個「女老師」。面對兩個男生的追求,一個和藹可親溫柔善良,一個冷酷霸道高傲冷漠,她會如何選擇?她的真實身份該怎樣揭曉