我一直在迁移一些代码来更改标头的声明,因为它们不包含在我的 Ubuntu 环境中。我终于更改了所有文件,但收到以下错误:
Item.h:33: error: reference to ‘ostream’ is ambiguous
Item.h:16: error: candidates are: struct ostream
/usr/include/c++/4.4/iosfwd:130: error: typedef struct
std::basic_ostream<char, std::char_traits<char> > std::ostream
Item.h:33: error: ISO C++ forbids declaration of ‘ostream’ with no type
Item.h:33: error: ‘ostream’ is neither function nor member function; cannot be declared friend
代码如下:
class Item
{
public:
Item( //const Wrd* hd,
const Term * _term, int _start, int _finish );
~Item();
int operator== (const Item& item) const;
friend ostream& operator<< ( ostream& os, const Item& item ); // <-- error
任何人都知道我将如何纠正这个问题?