Вопрос

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;

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top