标题:[求助]c++基础问题
取消只看楼主
cl_zdl
Rank: 1
等 级:新手上路
威 望:1
帖 子:71
专家分:0
注 册:2006-10-11
 问题点数:0 回复次数:0 
[求助]c++基础问题

大家帮我看看谢谢!
#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)

搜索更多相关主题的帖子: include public 
2006-10-17 08:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-96823-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.073717 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved