代码错误在何处,求详解?
#include<iostream>using namespace std;
struct Base1 {int x;}; //结构体Base1定义
struct Base2 {float y;}; //结构体Base2定义
struct Derived:Base1,Base2{}; //派生类结构体Derived,基类为Base1,Base2,默认继承方式为公有继承
int main(){ //主函数
Derived *pd=new Derived;
pd->x=1;pd->y=2.0f;
void *pv=pd;
Base2*pd=static_cast<Base2*>(pv);
cout<<pd->y<<" "<<pb->y<<endl;
delete pb;
return 0;
}