We can't create an object of an abstract class, right? So how can I call a virtual function which has definition in both abstract base class and derived class? I want to execute the code in abstract base class but currently, I am using derived class's object.
class T
{
public:
virtual int f1()=0;
virtual int f2() { a = 5; return a }
}
class DT : public T
{
public:
int f1() { return 10; }
int f2() { return 4; }
}
int main()
{
T *t;
t = new DT();
............
}
Is there any way I can call the base class function using the object t? If it is not possible, what should I need to do to call the base class function?