|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<iostream>
#include<string>
class Person
{
public:
Person(std::string theName);
void introduce();
protected:
std::string name;
};
class Teacher : public Person
{
public:
Teacher(std::string theName,std::string theClass);
void teach();
void introduce();
protected:
std::string classes;
};
class Student : public Person
{
public:
Student(std::string theName,std::string theClass);
void attendClass();
void introduce();
protected:
std::string classes;
};
class TeachingStudent : public Student,public Teacher
{
public:
TeachingStudent(std::string theName,std::string classTeaching,std::string classAttending);
void introduce();
};
Person::Person(std::string theName)
{
name = theName;
}
void Person::introduce()
{
std::cout << "大家好,我是" << name << "。\n\n";
}
Teacher::Teacher(std::string theName,std::string theClass) : Person(theName)
{
classes = theClass;
}
void Teacher::teach()
{
std::cout << name << "教" << classes <<"。\n\n";
}
Student::Student(std::string theName,std::string theClass) : Person(theName)
{
classes = theClass;
}
void Student::attendClass()
{
std::cout << name << "加入" << classes << "学习。\n\n";
}
TeachingStudent::TeachingStudent(std::string theName,
std::string classTeachenging,
std::string classAttending) : Teacher(theName,classTeaching),Student(theName,classAttending)
{
}
void TeachingStudent::introduce()
{
std::cout << "大家好,我是" << Student::name << "。我教" << Teacher::classes ;
std::cout << " ,同时也在" << Student::classes << "读书" ;
}
int main()
{
Teacher teacher("张12","入门班");
Student student("李一一","入门班");
TeachingStudent zhujiao("张二二","入门班","进阶班");
teacher.introduce();
teacher.teach();
student.introduce();
student.attendClass();
zhujiao.introduce();
zhujiao.teach();
zhujiao.attendClass();
return 0;
}
上面是源码-------------------------------------------------------------------------下面是问题-------------------------------------------------------------
error: converting to execution character set: Illegal byte sequence|(错误类型都是这种)
|
|