I have a problem in C++ multiple inheritance. here is my code and when I call display() function it is giving me request for member `display' is ambiguous. But Class M display() function is private.
#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
class M
{
void display()
{
cout<<"Class M"<<endl;
}
};
class N
{
public:
void display()
{
cout<<"Class N"<<endl;
}
};
class P:public M,public N
{
};
int main()
{
P *ob = new P();
ob->display(); // Why its giving me ambiguity error? Since only one copy is there right!!
getch();
return 0;
}
Can any one tell why exactly this problem?
M, the call is ambiguous. Try using the scope resolution operator::to help resolve where the call should be made: msdn.microsoft.com/en-us/library/b451xz31.aspxusing N::displayin the public interface ofP.