note: candidates are: virtual void CHandle::OnExcute(int, char*, int&, char*, int&)

在写纯虚函数的时候,发现一个诡异的问题,我再基类中定义了纯虚函数,但是在实现类中,怎么调用也不对,最后发现是引用的问题,我怀疑的gcc编译器的bug,但是没有深入研究。现记录如下:

#include <map>

class A
{
protected:
	A(){};
public:
	virtual ~A(){};
	virtual void do_something(int iMsgID,char* pBuffer,int& iLen) = 0;
};

class B:public A
{
public:
	B(){};
	virtual ~B(){}

	virtual void do_something(int iMsgID,char* pBuffer,int& iLen);
};

void B::do_something(int iMsgID,char* pBuffer,int& iLen)
{
	printf("do_something\n");
}

int main()
{
	std::map<int,A*> mpFunc;
	B BEx;
	mpFunc.insert(std::make_pair(1,&BEx));

	int iMsgID = 1;
	char szBuffer[100] = {0};
	int iLen = 0
	std::map<int,A*>::iterator it = mpFunc.find(1);
	if(it != mpFunc.end())
	{
		A* pA = it->second;
		if(pA)
		{
			pA->do_something(iMsgID,szBuffer,iLen);
		}
	}
}

编译报错: note: candidates are: virtual void XXXX

修改:把

do_something(int iMsgID,char* pBuffer,int& iLen)
中的int& 引用方式改为<pre name="code" class="cpp">do_something(int iMsgID,char* pBuffer,int* iLen)

 
则正确,编译通过!!!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Title: OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 Author: Jeanne Boyarsky, Scott Selikoff Length: 432 pages Edition: 1 Language: English Publisher: Sybex Publication Date: 2014-12-31 ISBN-10: 1118957407 ISBN-13: 9781118957400 Full coverage of functional programming and all OCA Java Programmer exam objectives OCA, Oracle Certified Associate Java SE 8 Programmer I Study Guide, Exam 1Z1-808 is a comprehensive study guide for those taking the Oracle Certified Associate Java SE 8 Programmer I exam (1Z1-808). With complete coverage of 100% of the exam objectives, this book provides everything you need to know to confidently take the exam. The release of Java 8 brought the language's biggest changes to date, and for the first time, candidates are required to learn functional programming to pass the exam. This study guide has you covered, with thorough functional programming explanation and information on all key topic areas Java programmers need to know. You'll cover Java inside and out, and learn how to apply it efficiently and effectively to create solutions applicable to real-world scenarios. * Work confidently with operators, conditionals, and loops * Understand object-oriented design principles and patterns * Master functional programming fundamentals Table of Contents Chapter 1 Java Building Blocks Chapter 2 Operators and Statements Chapter 3 Core Java APIs Chapter 4 Methods and Encapsulation Chapter 5 Class Design Chapter 6 Exceptions Appendix A Answers to Review Questions Appendix B Study Tips

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值