节俭 C++编译提供的教程时出现问题 - 无法在 TProcessor 上实例化抽象类
我正在尝试编译 Thrift 0.5.0 中给出的示例 C++ 教程。我按照教程\自述文件中的说明进行操作,并且能够毫无问题地生成示例计算器代码。但是当我尝试编译 Calculator_server.cpp 时,出现错误:
error C2259: 'tutorial::CalculatorProcessor' : cannot instantiate abstract class due to following members:
'bool apache::thrift::TProcessor::process(boost::shared_ptr<T>,boost::shared_ptr<T>,void *)' : is abstract with
[ T=apache::thrift::protocol::TProtocol ]
知道为什么会发生这种情况吗?我还没有接触过 TProcessor,它被列为抽象对象。 (注:我也在使用 THRIFT-1031 Apache Patch 在 VC++ 中进行编译)
I am trying to compile the sample c++ tutorial given in Thrift 0.5.0. I followed the directions in the tutorial\README and was able to generate the example Calculator code with no problem. But when I try and compile Calculator_server.cpp, I get the error:
error C2259: 'tutorial::CalculatorProcessor' : cannot instantiate abstract class due to following members:
'bool apache::thrift::TProcessor::process(boost::shared_ptr<T>,boost::shared_ptr<T>,void *)' : is abstract with
[ T=apache::thrift::protocol::TProtocol ]
Any idea why this is occurring? I haven't touched TProcessor and it is listed as an abstract object. (Note: I am also compiling in VC++ using THRIFT-1031 Apache Patch)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
出现此错误的原因是因为您无法创建
抽象类
的对象Aapache::thrift::TProcessor
是一个抽象类,这意味着它具有纯虚拟方法,要么直接在类中定义,要么从基类继承。就你而言,显然是后者。
您想要做的是实现继承的纯虚拟方法
bool apache::thrift::TProcessor::process()
,方法的签名应该完全相同。您将离开基础纯虚拟方法方法不变。而且你的课程仍然是抽象的。因此出现错误消息。The reason why you get this error is because you cannot create objects of an
Abstract Class
Aapache::thrift::TProcessor
is an abstract class, which means that it has pure virtual methods, either directly defined in the class, or inherited from base class.In your case, it's clearly the latter.
What you want to do is implement inherited pure virtual method
bool apache::thrift::TProcessor::process()
,the signature of the methods should be exactly the same.You are leaving the base pure virtual method unchanged. And your class is still abstract. Hence the error message.嗯,就是这样,显然 bool apache::thrift::TProcessor::process( .. ) 没有在共享::SharedServiceProcessor 中实现
Well it is what it is, apparently bool apache::thrift::TProcessor::process( .. ) is not implemented in shared::SharedServiceProcessor