我有基类Employee和两个子类Programmer和Analyst,它们实际上继承了基,我也有另一个类Leader,它们从这两个子类继承。 Employee具有我初始化对象时要获取当前日期的日期类型,以及其他几个字符串字段。当我尝试打印Leader时,我会丢失基类中除日期以外的所有数据。丢失的数据显示为空白空间,其他所有运行正常。
class Analyst : virtual public Employee
{
Analyst(**parameters**)
:Employee(name, surname, egn, position, leader, level)
{
this->analysisProject = analysisProject;
this->clientsEmails = clientsEmails;
}
}
class Programmer : virtual public Employee
{
Programmer(**parameters**)
:Employee(name, surname, egn, position, leader, level)
{
this->programmingProject = programmingProject;
}
}
class Leader : public Programmer, public Analyst {
// This is how i initialize the Leader class and where i suspect the problem is.
Leader(**parameters**)
: Analyst(name , surname, egn, position, leader, level, analysisProject, clientsEmails),
Programmer(name, surname, egn, position, leader, level, programmingProject)
{
}
我尝试了访问基本类getter的方法,它们运行时没有任何错误,但结果是相同的。 如有必要,我将提供更多代码。预先感谢。