#include using namespace std; class A { int a; int b; public: void eat() { cout<<\"A::eat()\"<
First of all, obj does not have a member named B. It Inherits from B, which means that it inherits all of B's members as its own.
obj
You can call:
foo(static_cast(&obj));