首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >成员nci的请求不明确

成员nci的请求不明确
EN

Stack Overflow用户
提问于 2014-05-21 22:02:16
回答 1查看 316关注 0票数 0

我的助理教授类是从两个类派生的: enseigner类(派生自personal)和PHD student (派生自Student类,学生类派生自peronal),我得到以下错误

“成员nci的请求不明确”

nci是personal的私人成员

代码语言:javascript
复制
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";
        }
      }
EN

回答 1

Stack Overflow用户

发布于 2014-05-21 22:10:07

这个问题:Diamond inheritance (C++)可能会帮助你理解所发生的事情。您在两个继承路径中使用了一个从Personal派生的类的实例,因此包含两个nci副本。因此,当简单地引用nci时,您的类实例不知道要使用哪个nci副本。

有许多技术可以解决这个问题,但它们取决于您的代码结构。考虑一下多重继承、菱形继承和虚拟继承。众所周知,这样的结构很难正确处理。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23785515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档