# **[](https://en.cppreference.com/w/cpp/header/ostream)** defines `std::basic_ostream` and `std::ostream`, the base classes for output streams. It provides `operator<<` for formatted output, `put()`, `write()`, and `flush()`. Most code uses `std::cout` or file output streams that inherit from this class. ## Example This example writes formatted output to a generic ostream reference and explicitly flushes the stream. ```cpp // compile: g++ -std=c++11 -o ostreamexample ostreamexample.cpp // run: ./ostreamexample // description: write to output stream #include #include int main() { std::ostream& out = std::cout; out << "hello " << 42 << " " << 3.14 << "\n"; out.flush(); return 0; } ```