I will form the question better through an example.
I want to extend the defult implementation of Qtcpsocket
the following way:
class NumberedTcpSocket : public QTcpSocket
{
Q_OBJECT
public:
NumberedTcpSocket(QObject *parent=0);
int number;
};
The only thing i'm doing here is adding a int number
field to the default implementation of QTcpSocket. I need this to enumerate opened sockets.
However, the rest of the networking classes work with, or return a Qtcpsocket
. It doesn't matter that the change i did is small.
I would like to do something like this:
NumberedTcpSocket *clientConnection = returnsPointerToQTcpSocket();
clientConnection->number = predefined_number;
What kind of casting needs to be done in this situation? Does it include a change in the constructor of the NumberedTcpSocket
?