When I have something like this:
class A
{
virtual void rat();
};
class B : public A
{
virtual void rat() { ; }
};
int main(int argc, char **argv)
{
A *a = new B;
delete a;
}
I get linker errors:
unless I make the base rat pure virtual.
However, when I have this:
class A
{
public:
void rat();
};
int main(int argc, char **argv)
{
A a;
}
This compiles fine and does not give me a link to an undefined link unless I explicitly try to call the rat function in my main ( a.rat();). What is the rule for unrealized virtual functions of a base class, which, however, are implemented in a derived class, as in the first code fragment with an error?
source
share