Hi!
I'm running (Ubuntu 9.04):
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The following code does compile:
class A {
public:
virtual void a() = 0;
void a(int i) {
a();
}
};
class B : public A {
public:
void a() {
}
};
int main (int argc, char ** argv) {
B b;
b.a(1); // do not compile
static_cast<A&>(b).a(1); // compiles
return 0;
}
I got the following:
benny@PC-besj:~$ g++ -c test.cpp
test.cpp: In function ‘int main(int, char**)’:
test.cpp:18: error: no matching function for call to ‘B::a(int)’
test.cpp:11: note: candidates are: virtual void B::a()
benny@PC-besj:~$
I supose it should be possible to call a overloaded method from the base
class (without static_cast<...>),
void a(int) indeed exists in A class.
Or am I wrong ??
Best regards!
/Benny
class A {
public:
virtual void a() = 0;
void a(int i) {
a();
}
};
class B : public A {
public:
void a() {
}
};
int main (int argc, char ** argv) {
B b;
b.a(1); // do not compile
static_cast<A&>(b).a(1); // compiles
return 0;
}