关于c++菱形多继承的一个问题
```c++
#include <iostream>
#include <string>
//实现多继承
class Person
{
public:
Person(std::string);
void introduce();
protected:
std::string name;
};
Person::Person(std::string thename)
{
thename = name;
}
void Person::introduce()
{
std::cout << "我的名字叫:" << this->name << std::endl;
}
class Teacher :public Person
{
public:
Teacher(std::string, std::string);
void teach();
protected:
std::string TeachClass;
};
Teacher::Teacher(std::string thename, std::string TeachClass):Person(thename)
{
this->TeachClass = TeachClass;
}
void Teacher::teach()
{
std::cout << "我教的课程叫:" << this->TeachClass << std::endl;
}
class Student :public Person
{
public:
Student(std::string, std::string);
protected:
std::string StudyClass;
};
Student::Student(std::string thename, std::string StudyClass):Person(thename)
{
this->StudyClass = StudyClass;
}
class TeachingStudent:public Student, public Teacher
{
public:
TeachingStudent(std::string, std::string, std::string);
void print();
};
TeachingStudent::TeachingStudent(std::string thename, std::string StudyClass, std::string TeachClass) :Student(thename, StudyClass), Teacher(thename, TeachClass)
{
}
void TeachingStudent::print()
{
std::cout << Student::name << "在" << this->StudyClass << "学习并教" << this->TeachClass << std::endl;//此处的Student::name为什么打印出来是空白
}
int main()
{
TeachingStudent a("小明", "机电6班", "机电5班");
a.print();
return 0;
}
```