skip to content
Ivan's wiki
Site Tools
Search
Tools
Show pagesource
Backlinks
Recent Changes
Media Manager
Sitemap
>
Recent Changes
Media Manager
Sitemap
hpp-iosfwd
This page is read only. You can view the source, but not change it.
# <iosfwd> **[<iosfwd>](https://en.cppreference.com/w/cpp/header/iosfwd)** provides forward declarations of stream classes without including the full implementation. Use it in header files when you want to accept a stream parameter or return type without pulling in the heavy iostream headers. It's a small optimization to reduce compile times. This example declares a function that takes an ostream parameter using only forward declarations, avoiding the overhead of including iostream. ```cpp // compile: g++ -std=c++11 -o iosfwdexample iosfwdexample.cpp // run: ./iosfwdexample // description: forward declaration of ostream in a header #include <iosfwd> #include <iostream> void print_message(std::ostream& out); void print_message(std::ostream& out) { out << "hello from iosfwd\n"; } int main() { print_message(std::cout); return 0; } ```
Page Tools
Show pagesource
Backlinks
Back to top