Statischer Elementfunktionsfehler; Wie schreibe ich die Signatur richtig?
Ich erhalte eine Fehlermeldung, wenn Sie versuchen zu kompilieren meines Codes in g++ mit der aktuellen Signatur:
cannot declare member function static void Foo::Bar(std::ostream&, const Foo::Node*) to have static linkage
Meine Frage ist eine doppelte:
- Warum es nicht Kompiliert werden, auf diese Weise?
- Was ist die richtige Signatur und warum?
Signaturen waren schon immer der Tod an mich, wenn Sie mit C++
Edit: Hier ist die Klasse header-Datei:
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);
InformationsquelleAutor der Frage Joshua | 2011-11-15
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich vermute, Sie haben etwas getan, wie:
"
static void Foo::Bar
"Ist falsch. Sie brauchen nicht den zweiten "static
".InformationsquelleAutor der Antwort Oliver Charlesworth