I have a class and a structure inside the class like that :
class MyClass : public QObject
{
public:
....
struct MyStruct
{
quint8 val1;
}
};
I would like to overload the operators << and >> for the struct, but I don't know how to do. For the moment, I do like that :
class MyClass : public QObject
{
public:
....
struct MyStruct
{
quint8 val1;
QDataStream &operator<<(QDataStream &out, const MyStruct& _myStruct)
{
out << _myStruct.val1;
return out;
}
QDataStream &operator>>(QDataStream &in, MyStruct& _myStruct)
{
in >> _myStruct.val1;
return in;
}
};
};
but it is not OK