Search code examples
c++thrift

Thrift C++ Trouble compiling provided Tutorial - Cannot Instantiate Abstract Class on TProcessor


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)


Solution

  • 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.