#include <iostream>
using std::cout;
using std::endl;
struct A {
void f() const {
std::cout << "struct A" << endl;
}
};
struct B : A {
void f() const {
std::cout << "struct B" << endl;
}
};
int main()
{
B b1;
A& a = b1;
a.f();
B& b2 = static_cast<B&>(a);
b2.f();
return (0);
}
/*
run:
struct A
struct B
*/