error C2385: 'p2in1::Eject' is ambiguous

P

Prakru

Hello guys,


I get compilation error [error C2385: 'p2in1::Eject' is ambiguous]
for the following code in MS VC++ 6 compiler:
I thought that if the Eject is called with no args, then the
Player::Eject ()
should be called.

But it is not working.
Please explain



#include <iostream.h>


class Player
{
public :
void Eject ()
{
cout << "player " ;
}
};



class CDPlayer : virtual public Player
{
public :
void Eject (int i){
cout << "CDplayer " ;
}
};


class Tape : virtual public Player
{
public :
void Eject (){
cout << "Tape player " ;

}
};


class p2in1 : public CDPlayer , public Tape
{

};


void main ()
{
p2in1 t1;

t1.Eject ();
}
 
K

Karthik

Prakru said:
Hello guys,


I get compilation error [error C2385: 'p2in1::Eject' is ambiguous]
for the following code in MS VC++ 6 compiler:
I thought that if the Eject is called with no args, then the
Player::Eject ()
should be called.

What about the method with the same signature in Tape. There is no
way a compiler can resolve between the two since the two are in the same
hierarchy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top