What is wrong with this code:
Code:
#include <iostream>
using namespace std;
class AbstractClass
{
public:
virtual void Func();
virtual void Func(int x) = 0;
};
class DerivedClass : public AbstractClass
{
virtual void Func(int x);
};
void AbstractClass::Func()
{
Func(3);
}
void DerivedClass::Func(int x)
{
cout << " x is " << x << "\n";
}
int main(void)
{
DerivedClass d;
d.Func();
}
When I compile it it says no matching function call to DerivedClass::Func().
If I change the following it works:
Code:
int main(void)
{
AbstractClass *d = new DerivedClass;
d->Func();
delete d;
}
Or, if I change the name Func(int x) to Foo(int x) it works. Why cant I overload Func with a pure virtual function?
Thanks,
Bob