C++ ostream and ofstream conversions
Yes, you can. That's the point in the OO concept called subtype polymorphism. Since ofstream
derives from ostream
, every instance of ofstream
is at the same time an instance of ostream
too (conceptually). So you can use it wherever an instance of ostream
is expected.