0

我对 Eclipse Kepler 有疑问。在头文件中,我声明了一个类和友元运算符<<:

// Foo.h
class Foo {
public:
    friend std::ostream & operator <<( std::ostream &os, const Foo &foo );
private:
    int n_;
};

在源文件中我实现它:

// Foo.cpp
std::ostream & operator <<( std::ostream &os, const Foo &foo ) {
    return os << foo.n_;
}

代码编译并运行良好,但编辑器中的 Eclipse 在行显示错误“成员函数'n_'不可见”

return os << foo.n_;

如果我在 Foo.h 中实现该功能,Eclipse 不会显示错误。哪个是问题?谢谢!

4

0 回答 0