understanding overloaded << and >>

I need to create an overloaded << & >> for a class. I was wondering if someone knew a good resource for how to write one.

Also I would like to know specifically what would go on the left side of this operator should I overload it when I call it in main();.

Dan Schwartz
Basically << means to output a value while >> means to assign a value

Try reading this: http://www.fredosaurus.com/notes-cpp/oop-friends/overload-io.html

An extract from the website:

1
2
3
4
ostream& operator<<(ostream& output, const Point& p) {
    output << "(" <<  p.x << ", " << p.y <<")";
    return output;  // for multiple << operators.
}
sounds like a good starting place, I think I am going to look up more specific examples of how it is used in other classes though. Unless anyone else has more resources they know of I'll mark this as solved.

Topic archived. No new replies allowed.