Answer the question
In order to leave comments, you need to log in
Why make a virtual function in derived classes?
Good afternoon!
Sometimes I come across examples like this:
class BaseABC{
public:
virtual void test()const = 0;
...
}
class Heir : public BaseABC{
public:
virual void test()const;
...
}
//head.h
class TooHeir : public Heir{
public:
void test()const;
...
}
//realize.cpp
void TooHeir::test()const{
std::cout<<"Invoked test() of object \"TooHeir\"";
}
//main.cpp
TooHeir * pth = new TooHeir;
pth->test();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question