What is wrong with this code:
When I compile it it says no matching function call to DerivedClass::Func().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(); }
If I change the following it works:
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?Code:int main(void) { AbstractClass *d = new DerivedClass; d->Func(); delete d; }
Thanks,
Bob



LinkBack URL
About LinkBacks



