Error overloading >> operator
Solved
General and Desktop
-
Hello,
I am trying to overload the >> operator in a class, like this:
class Sample { private: quint8 tag; quint32 time; qint16 val1; qint16 val2; qint16 val3; qint16 val4; public: Sample(); friend QDataStream &operator>> (QDataStream &in, Sample &samp) { in >> samp.tag >> samp.time >> samp.val1 >> samp.val2 >> samp.val3 >> samp.val4; return in; } };
But I have a complain saying "invalid operand between Qdatastream and Qint8". I actually was doing the same in a struct instead of a class and it was working.
Any idea ?Best
-
Hi @KillerSmath . Exactly. I was actually doing all of these using struct, but I want to do it as Class now.
-
I would guess you're missing to include the QDataStream header.
-
@Christian-Ehrlicher . That was exactly the issue ! Thank you so much, did not expect this from the error message.