当我的界面(带有所有纯虚拟功能)需要一个以上的功能,而我却忘记将其“清空”时,我也遇到了同样的错误。
我有
class ICommProvider
{
public:
/**
* @brief If connection is established, it sends the message into the server.
* @param[in] msg - message to be send
* @return 0 if success, error otherwise
*/
virtual int vaSend(const std::string &msg) = 0;
/**
* @brief If connection is established, it is waiting will server response back.
* @param[out] msg is the message received from server
* @return 0 if success, error otherwise
*/
virtual int vaReceive(std::string &msg) = 0;
virtual int vaSendRaw(const char *buff, int bufflen) = 0;
virtual int vaReceiveRaw(char *buff, int bufflen) = 0;
/**
* @bief Closes current connection (if needed) after serving
* @return 0 if success, error otherwise
*/
virtual int vaClose();
};
最后一个vaClose不是虚拟的,因此编译后不知道从何处获取实现,因此感到困惑。我的讯息是:
... TCPClient.o :(。rodata + 0x38):对`typeInfo for ICommProvider'的未定义引用
简单的改变
virtual int vaClose();
至
virtual int vaClose() = 0;
解决了问题。希望能帮助到你