C
Carlos Martinez Garcia
Hi all:
I have a problem compiling a file and I can't understand why.
Here is my code:
class Base {
public:
virtual void foo()=0;
virtual void foo(int i) {
int j=i;
}
virtual void foo(int i, int i2, int i3) {
int j=i;
}
};
class Derived
ublic Base {
public:
void foo() {}
void foo(int i,int i2,int i3) {
int j=i+5;
}
};
int main() {
Derived d;
d.foo(15);
return 0;
}
The compiler's output:
main.cc: En function `int main()':
main.cc:23: error: no matching function for call to `Derived::foo(int)'
main.cc:14: error: candidates are: virtual void Derived::foo()
main.cc:15: error: virtual void Derived::foo(int, int, int)
Why compiler doesn't see foo(int)?
It must be Base::foo(int). Isn't it?
If I change foo(int) to foo2(int), there's no errors. Why?
Thanks in advance
I have a problem compiling a file and I can't understand why.
Here is my code:
class Base {
public:
virtual void foo()=0;
virtual void foo(int i) {
int j=i;
}
virtual void foo(int i, int i2, int i3) {
int j=i;
}
};
class Derived
public:
void foo() {}
void foo(int i,int i2,int i3) {
int j=i+5;
}
};
int main() {
Derived d;
d.foo(15);
return 0;
}
The compiler's output:
main.cc: En function `int main()':
main.cc:23: error: no matching function for call to `Derived::foo(int)'
main.cc:14: error: candidates are: virtual void Derived::foo()
main.cc:15: error: virtual void Derived::foo(int, int, int)
Why compiler doesn't see foo(int)?
It must be Base::foo(int). Isn't it?
If I change foo(int) to foo2(int), there's no errors. Why?
Thanks in advance