C++问题,有空的来看看,帮解决个问题
谁能帮解释下这个程序?主要是什么会输出100?#include<iostream.h>
class base{};
class derived1:public base
{
private:
int d_a1;
int d_b1;
public:
void display_a(void)
{
cout<<"d_a1 ="<<d_a1<<endl;;
}
};
class derived2: public base
{
public:
int d_a2;
int d_b2;
};
void main()
{
int base::*p;
p=(int base::*)&derived2::d_a2;
derived1 d1;
d1.*p=100;
d1.display_a();
}