私は、このインターフェイスがあります。私のクラスはどのようにインターフェイスとQObjectを継承できますか?
class ISocketClient
{
public:
~ISocketClient() {}
virtual bool connectToHost(std::string const &hostname, unsigned short port) = 0;
virtual void closeClient() = 0;
virtual bool sendMessage(Message &) = 0;
virtual Message *getMessage() = 0;
};
をそしてこれが継承する私のクラスでは、次のとおりです。
class TCPClient : public QObject, ISocketClient
{
Q_OBJECT
public:
TCPClient(QObject *parent = 0);
~TCPClient();
bool connectToHost(std::string const &hostname, unsigned short port);
void closeClient();
bool sendMessage(Message &);
Message *getMessage();
public slots:
void readMessage();
private:
QTcpSocket *tcpSocket;
};
しかし、私はこのエラーを持ってコンパイルします。
/home/danilo_d/Epitech-Projects/Semestre5/QtNetworkTest/TCPClient.cpp:4: error: undefined reference to `vtable for TCPClient'
そして、私は取ります私のQObjectの継承を、それは動作します。
どうすればいいですか?
あなたは 'TCPClient.cpp'を表示できますか? –
私はあなたが望むと思います: 'class TCPClient:public QObject、public ISocketClient'、とにかく'〜ISocketClient(){} 'は仮想でなければなりません – Danh
@ user3528438本当ですか?それは私が[Multiple Inheritance Requires QObject To First](http://doc.qt.io/qt-4.8/moc.html#multiple-inheritance-requires-qobject-to-be-first)の要件をどのように読んでいるかではありません。 –