Assigning QTcpSocket object
-
05-06-2021 - |
Pergunta
I have a class with QTcpSocket socket;
as private member. Then, in class constructor I'm initialising with socket = new QTcpSocket();
When compiling, I'm getting error:
error: no match for ‘operator=’ in ‘((MyClass*)this)->MyClass::socket = (operator new(16u), (<statement>, ((QTcpSocket*)<anonymous>)))’
What's wrong?
Solução
check declaration: if you wrote QTcpSocket socket;
you declare a object not a pointer. In this case you can t construct it with new
.
You should declare QTcpSocket* socket;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow