尝试使用当前签名在 g++ 中编译我的代码时出现错误:
cannot declare member function static void Foo::Bar(std::ostream&, const Foo::Node*) to have static linkage
我的问题是双重的:
- 为什么它不以这种方式编译?
- 什么是正确的签名,为什么?
使用 C++ 时,签名一直是我的死因
编辑:这里也是类头文件:
class Foo {
public:
Foo();
~Foo();
bool insert(const Foo2 &v);
Foo * find(const Foo2 &v);
const Foo * find(const Foo2 &v) const;
void output(ostream &s) const;
private:
//Foo(const Foo &v);
//Foo& operator =(const Foo &v);
//Not implemented; unneeded
struct Node {
Foo2 info;
Node *left;
Node *right;
};
Node * root;
static bool insert(const Foo2 &v, Node *&p);
static void output(ostream &s, const Node *p);
static void deleteAll(Node *p);