我的助理教授课程来自两个班级:enseigner课程(源自个人)和PHD学生(来自学生班级和学生班级来自个人) 我收到以下错误
"成员nci的请求不明确"
nci是个人的私人会员
enter code here
#include<iostream>
using namespace std;
#include "enseigneer.h"
#include "assistant_professor.h"
#include "associate_professor.h"
#include "professor.h"
void assistant_delete(assistant_professor**head_assis,assistant_professor **tail_assis)
{
int number;int pos=0;int sz=0;
assistant_professor *temp;
assistant_professor *search_1;
assistant_professor *current;
assistant_professor *to_free;
temp=*head_assis;
current=*head_assis;
cout<<"Enter the CIN number of the enseigner that you want to delete\n ";
cin>>number;
if(head_assis==NULL)cout<< "The list is empty you have to enter data first\n";
else
{
while (search_1!=NULL)
{
search_1=search_1->next;sz=sz+1;
}
if ((*head_assis)-> nci==number)
{
to_free=*head_assis;
(*head_assis)=(*head_assis)->next;
delete (to_free);
cout<< "\nThe student was deleted\n";
}
else if ((*tail_assis)->nci==number)
{
for (int i=0;i<sz-3;i++)
current=current->next;
delete(current->next);
current->next=NULL;
*tail_assis=current;
cout<< "\nThe enseigner was deleted\n";
}
else
{
{
while((temp!=NULL) and ((temp->nci)!=number))
{
temp=temp->next;pos=pos+1;
}
if (temp->next==NULL) cout<<"Please pay attention the enseigner you've entred doesn't exist in the list\n";
else
{
for (int i=0;i<pos-1;i++)
current=current->next;
to_free=current->next;
current->next=current->next->next;
delete(to_free);cout<< "\nThe enseigner was deleted\n";
}
}
答案 0 :(得分:0)
这个问题:Diamond inheritance (C++)可能会帮助您了解正在发生的事情。您正在使用从两个继承路径中的Personal派生的类的实例,因此包含两个nci
副本。因此,当简单引用nci
时,您的类实例不知道要使用哪个nci
副本。
有许多技巧可以解决这个问题,但它们取决于你的代码结构。考虑阅读多重继承,钻石继承和虚拟继承。这样的结构对于正确的做法是非常棘手的。