Reputation: 22926
void operator<< (const Integer& left, const Integer& right)
{
cout << "\n: " << right.i;
}
can be accessed like:
Integer obj;
obj << 5 << 3 << 2;
Fine:
But qDebug
works like qdebug() << 2;
Which means that the left operand of <<
operator is a function.
What should be the syntax of a user defined function so that I can write:
myfunc() << 2;
Upvotes: 0
Views: 279
Reputation: 726639
The left operand is not a function, it is the value the function returns. Specifically, qDebug()
returns an instance of QDebug
, which has some 20 overloads of <<
defined.
Upvotes: 5