Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I need to include in my header file for ostream

Tags:

c++

header

g++

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

ostream & Print (ostream & stream);

How can this be fixed?

like image 728
neuromancer Avatar asked May 22 '10 09:05

neuromancer


2 Answers

If you #include <ostream>, ostream will be defined in the std namespace:

#include <ostream>

// ...

std::ostream & Print (std::ostream & stream);
like image 85
GManNickG Avatar answered Nov 15 '22 01:11

GManNickG


Use 'using' if you don't want to pull the whole std namespace, eg :

#include <iosfwd>
using std::ostream;
like image 28
OneOfOne Avatar answered Nov 14 '22 23:11

OneOfOne