What I need to include in my header file for ostream

When I try to compile my program, the compiler complains about this line in the .h file that I included #.

ostream & Print (ostream & stream);

How can this be fixed?

+5
source share
3 answers

If you do #include <ostream>, ostreamit is defined in a namespace std:

#include <ostream>

// ...

std::ostream & Print (std::ostream & stream);
+9
source

Use 'using' if you do not want to stretch the entire std namespace, for example:

#include <iosfwd>
using std::ostream;
+1
source

:

#include <iosfwd>
using namespace std;
0

All Articles