开发者

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

开发者 https://www.devze.com 2022-12-31 12:10 出处:网络
When I try to compile my program the compiler complains about this line in a .h file that I #included.

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

ostream & Print (ostream & stream);

Ho开发者_如何转开发w can this be fixed?


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

#include <ostream>

// ...

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


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

#include <iosfwd>
using std::ostream;


Minimal code for this declaration to compile:

#include <iosfwd>
using namespace std;
0

精彩评论

暂无评论...
验证码 换一张
取 消