i have a class:
class Y{ public: int x; Y(); }; Main:
int main(){ Y y; y.x = 10; y << mystream; return 0; } I just wanna to cause any action when y<<mystream is typed. I tried in my class header like those:
friend Y mystream(Y y); friend ostream mystream(ostream o, Y y) And etc. but nothing didn't work. Any ideas to custom this stream?
Best regards!
y << streaminstead ofstream << y, since the latter is how the<<operator is usually invoked on a stream.