Jos*_*hua 161 c++ static-members method-signature static-functions
尝试使用当前签名在g ++中编译我的代码时出错:
cannot declare member function static void Foo::Bar(std::ostream&, const Foo::Node*) to have static linkage
Run Code Online (Sandbox Code Playgroud)
我的问题是双重的:
在使用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);
Run Code Online (Sandbox Code Playgroud)
Oli*_*rth 411
我猜你做过类似的事情:
class Foo
{
static void Bar();
};
...
static void Foo::Bar()
{
...
}
Run Code Online (Sandbox Code Playgroud)
" static void Foo::Bar"不正确.你不需要第二个" static".