2014-05-21 28 views
0

我的助理教授課程來源於兩個班級:enseigner班級(來自個人)和PHD學生(來自學生班級和來自peronal的學生班級dervie) 我收到以下錯誤會員nci的請求含糊不清

「的成員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

的問題是如何解決錯誤,這是一個多重負擔! 「請求會員nci不明確」 – user3136456

回答

0

這個問題的私有成員:Diamond inheritance (C++)可以幫助你瞭解這是怎麼回事。您正在使用一個派生於兩個繼承路徑中的Personal類的實例,因此包含兩個nci副本。所以,當簡單引用nci時,您的類實例不知道要使用哪個副本nci

有很多技術可以解決這個問題,但它們取決於您的代碼結構。考慮閱讀多重繼承,鑽石繼承和虛擬繼承。這樣的結構在糾正錯誤方面非常棘手。