在'*'标记之前预期的构造函数,析构函数或类型转换

Fre*_*urn 11 c++

老实说,我不知道为什么会这样.我检查,双重检查,三重检查花括号,分号,移动构造函数等,它仍然给我这个错误.

相关代码如下.

BinTree.h

#ifndef _BINTREE_H
#define _BINTREE_H

class BinTree
{
private:
    struct Node
    {
        float data;
        Node *n[2];
    };
    Node *r;

    Node* make( float );

public:
    BinTree();
    BinTree( float );
    ~BinTree();

    void add( float );
    void remove( float );

    bool has( float );
    Node* find( float );
};

#endif
Run Code Online (Sandbox Code Playgroud)

和BinTree.cpp

#include "BinTree.h"

BinTree::BinTree()
{
    r = make( -1 );
}

Node* BinTree::make( float d )
{
    Node* t = new Node;
    t->data = d;
    t->n[0] = NULL;
    t->n[1] = NULL;
    return t;
}
Run Code Online (Sandbox Code Playgroud)

Mic*_*urr 21

因为在线:

Node* BinTree::make( float d )
Run Code Online (Sandbox Code Playgroud)

该类型Node是.的成员class BinTree.

做了:

BinTree::Node* BinTree::make( float d )
Run Code Online (Sandbox Code Playgroud)

  • 这很棘手.有趣的是,您不必使用`BinTree ::`限定*参数* - 仅返回类型. (2认同)