节俭 C++编译提供的教程时出现问题 - 无法在 TProcessor 上实例化抽象类

发布于 2024-11-04 13:58:53 字数 518 浏览 3 评论 0原文

我正在尝试编译 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞别 2024-11-11 13:58:53

出现此错误的原因是因为您无法创建抽象类的对象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.

夏日浅笑〃 2024-11-11 13:58:53

嗯,就是这样,显然 bool apache::thrift::TProcessor::process( .. ) 没有在共享::SharedServiceProcessor 中实现

Well it is what it is, apparently bool apache::thrift::TProcessor::process( .. ) is not implemented in shared::SharedServiceProcessor

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文