class A
{
public:
int a;
A() : a(100) { }
};
class B : public A
{
public:
int b;
B() : b(200){ }
};
int main()
{
A a;
B *ptrB =(B*)&a;
cout<<ptrB->b<<endl; // Is there a way to get this to print 200??
}
ahtaniv 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.