EE C++ compiler reports an error, but shouldn't
Posted: Sat Oct 15, 2005 9:09 pm
Hi.
I have a piece of code that the EE c++ compiler refuses to compile. I would believe that it is perfectly legit code, and the MS C++ also accepts it. It appears that if I have a base class that has a function that accepts a reference to a class instance, and I call that function from a subclass, it generates a compile error.
I made a simple file, bug.cpp
class A
{
int i;
};
class B
{
protected:
void test(A& a);
};
class C : public B
{
public:
void test();
};
void C::test()
{
A a;
test(a);
}
I compile the file using the command line: ee-g++ -c bug.cpp -o bug.o
The compile returns this output:
bug.cpp: In member function `void C::test()':
bug.cpp(22) : no matching function for call to `C::test(A&)'
bug.cpp(20) : candidates are: void C::test()
If I change the line
test(a);
to
B::test(a);
it compiles fine. But AFAIK, placing the class name where the function is to be found should only be required if there is an ambiguity, but I cannot see any amiguity here.
I'm compiling on a Windows installation using the "PS2Dev Environment for Win32".
I have a piece of code that the EE c++ compiler refuses to compile. I would believe that it is perfectly legit code, and the MS C++ also accepts it. It appears that if I have a base class that has a function that accepts a reference to a class instance, and I call that function from a subclass, it generates a compile error.
I made a simple file, bug.cpp
class A
{
int i;
};
class B
{
protected:
void test(A& a);
};
class C : public B
{
public:
void test();
};
void C::test()
{
A a;
test(a);
}
I compile the file using the command line: ee-g++ -c bug.cpp -o bug.o
The compile returns this output:
bug.cpp: In member function `void C::test()':
bug.cpp(22) : no matching function for call to `C::test(A&)'
bug.cpp(20) : candidates are: void C::test()
If I change the line
test(a);
to
B::test(a);
it compiles fine. But AFAIK, placing the class name where the function is to be found should only be required if there is an ambiguity, but I cannot see any amiguity here.
I'm compiling on a Windows installation using the "PS2Dev Environment for Win32".