M
Mihai Osian
Hi everyone,
Given the code below, can anyone tell me:
a) Is this normal behaviour ?
b) If it is, what is the reason behind it ? I would expect the
A::method(int) to be inherited by B.
Compiler: gcc 4.1, Linux
Thanks,
Mihai
-----------------------
#include <stdio.h>
class A{
public:
virtual void method(int);
};
class B: public A{
public:
virtual void method();
};
void A::method(int n){
fprintf(stderr, "A::method(%d)\n", n);
}
void B::method(){
fprintf(stderr, "B::method\n");
}
int main(int argc, char** argv){
B b;
b.method(3);
return 0;
}
-----------------
mike@nemesis:~/work/inh_test$ g++ -o main main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:31: error: no matching function for call to 'B::method(int)'
main.cpp:18: note: candidates are: virtual void B::method()
Given the code below, can anyone tell me:
a) Is this normal behaviour ?
b) If it is, what is the reason behind it ? I would expect the
A::method(int) to be inherited by B.
Compiler: gcc 4.1, Linux
Thanks,
Mihai
-----------------------
#include <stdio.h>
class A{
public:
virtual void method(int);
};
class B: public A{
public:
virtual void method();
};
void A::method(int n){
fprintf(stderr, "A::method(%d)\n", n);
}
void B::method(){
fprintf(stderr, "B::method\n");
}
int main(int argc, char** argv){
B b;
b.method(3);
return 0;
}
-----------------
mike@nemesis:~/work/inh_test$ g++ -o main main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:31: error: no matching function for call to 'B::method(int)'
main.cpp:18: note: candidates are: virtual void B::method()