Doubt on correctnes of code
[ Please CC: me in the replies since I'm not subscribed to this list ]
Hello,
The code below is compiled fine by g++-2.95 while g++-3.3 (version 3.3.1-1)
fails with the following message:
/home/goedson/teste.cc: In function `int main(int, char**)':
/home/goedson/teste.cc:22: error: conversion from `BClass' to `B*' is ambiguous
/home/goedson/teste.cc:16: error: candidates are: BClass::operator B*()
/home/goedson/teste.cc:9: error: AClass::operator A*()
My doubt is. What version of g++ is right? Is the code correct or, by
the C++ standard there is really an ambiguity?
Thanks in advance for any help,
Goedson
/////////// Code starts here ////////////////////////
typedef struct _A A;
typedef struct _A B;
void some_function(B *b);
class AClass {
public:
operator A*() { return 0;}
};
class BClass :public AClass {
public:
operator B*() { return 0;}
};
int main(int argc, char **argv) {
BClass b;
some_function(b);
}
Reply to: