Difference between ofstream and ostream operators

Hi, I'm trying to overload an operator << so that it prints to a .txt file.
Would these two codes basically do the same thing? If so, which one is the more efficient one to use?

1
2
3
4

ofstream& operator<<(ofstream& fout, const Grid& g);

ostream& operator<<(ostream & out, const Grid& g);


You only ever need to care about ostream. ofstream derives from ostream and so will bind to a reference of type ostream.
Oh, that's awesome! Thanks.
Topic archived. No new replies allowed.