首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >静态成员函数错误,如何正确写入签名?

静态成员函数错误,如何正确写入签名?
EN

Stack Overflow用户
提问于 2011-11-15 08:23:21
回答 1查看 90.5K关注 0票数 168

尝试使用当前签名在g++中编译代码时出现错误:

cannot declare member function static void Foo::Bar(std::ostream&, const Foo::Node*) to have static linkage

我的问题有两个:

  1. 为什么不这样编译?
  2. 正确的签名是什么?为什么?

在使用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);
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8130066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档