#include <iostream>
class A
{
public:
A(/* args */){};
virtual void p(){std::cout << "A\n";}
};
class B : public A
{
public:
B(/* args */){};
};
class C : public B
{
public:
C(/* args */){};
void p() override{std::cout << "C\n";}
};
int main(int argc, char const *argv[])
{
B test = C();
C test2 = C();
test.p();
test2.p();
return 0;
}
Curently it Prints: A C
I would like to save C in B form like the 'test' variable; but call the override version of the function, now it's calling the base one.