I want write a class which is inherit from QObject to the file with QDataStream, so I overload operator << and operator >>.
{
Q_OBJECT
......
.......
}
.................
{
}
{
}
Class C : public QObject
{
Q_OBJECT
......
friend QDataStream & operator << (QDataStream &dataStream, C &c);
friend QDataStream & operator >> (QDataStream &dataStream, C &C);
.......
}
.................
QDataStream & operator << (QDataStream &dataStream, C &c)
{
}
QDataStream & operator >> (QDataStream &dataStream, C &c)
{
}
To copy to clipboard, switch view to plain text mode
but it can't compile success.The error is:multiple definition of "operator" <<(QDataStream&,C&)
multiple definition of "operator" >>(QDataStream&,C&)
if this class is not inherit from the QObject and delete macro Q_OBJECT, then it will compile success. So What's the problem....?
Bookmarks