Assigning QTcpSocket object
-
05-06-2021 - |
Вопрос
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?
Решение
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;
Не связан с StackOverflow