I have a class A with method Hello:
class A {
public:
void Hello(){
std::cout << "Hi from class A!" << std::endl;
}
};
I then have a class B that inherits class A and has its own Hello method:
class B : public A {
public:
void Hello(){
std::cout << "Hi from class B!" << std::endl;
}
};
I create a new object of class B, and later cast it to be of type class A.
B myB;
A myA = static_cast<A>(myB);
How do I make it so myA.Hello();
prints "Hi from class B!"?