大家帮我看看谢谢!
#include<iostream>
using namespace std;
class Baseclass {
public: void fn1(){cout <<"你好"<<endl;}
void fn2(){cout<<"你好吗啊"<<endl;}
};
class Drivedclass :public Baseclass
{public:void fn1(){cout<<"我不好"<<endl;}
void fn2(){cout<<"我很好"<<endl;}
};
void main()
{Drivedclass p;
Drivedclass *p1=&p;
void (Baseclass:: *d_fn1)()=Baseclass::fn1;
void (Baseclass:: *d_fn2)()=Baseclass::fn2;
cout<<p1->fn1()<<endl<<p1->fn2()<<endl;
cout<<(p.*d_fn1)()<<endl;
cout<<p1->Baseclass::fn1()<<endl<<p1->Baseclass::fn2()<<endl;
}
错误调试:
--------------------Configuration: 22 - Win32 Debug--------------------
Compiling...
22.cpp
D:\学习文件\CL\7-11\22\22.cpp(16) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
D:\学习文件\CL\7-11\22\22.cpp(17) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
D:\学习文件\CL\7-11\22\22.cpp(18) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
执行 cl.exe 时出错.
22.obj - 1 error(s), 0 warning(s)