In the example below, I have an abstract class with a pure virtual method (aka FUN1) and a regular method (aka FUN2).
#include <iostream>
class A
{
public:
virtual void fun(int i) = 0;
void fun() { this->fun(123); }
};
class B : public A
{
public:
virtual void fun(int i) { std::cerr << i << std::endl; }
};
int main(int,char**)
{
B b;
b.fun();
}
Why can't I invoke FUN2 in a derived class? g ++ gives an error:
main.cpp: 19: 8: error: there is no corresponding function to call in B: fun ()
EDIT: note that the issue of Overloading a pure virtual function is different. I do not want to redefine methods.
source
share