By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

error C2385: 'p2in1::Eject' is ambiguous

P: n/a
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 ();
}
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Prakru wrote:
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.

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 ();
}

--
Karthik.
Humans please 'removeme_' for my real email.
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.