neuromancer
neuromancer

Reputation: 55559

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

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?

Upvotes: 7

Views: 10853

Answers (3)

OneOfOne
OneOfOne

Reputation: 99351

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

#include <iosfwd>
using std::ostream;

Upvotes: 3

BenG
BenG

Reputation: 1312

Minimal code for this declaration to compile:

#include <iosfwd>
using namespace std;

Upvotes: 0

GManNickG
GManNickG

Reputation: 504133

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

#include <ostream>

// ...

std::ostream & Print (std::ostream & stream);

Upvotes: 11

Related Questions