繁体   English   中英

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

[英]Expected constructor, destructor, or type conversion before '*' token

老实说,我不知道为什么会这样。 我检查,仔细检查和仔细检查了花括号,分号,四处移动的构造函数等,它仍然给我这个错误。

相关代码如下。

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

还有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;
}

因为在网上:

Node* BinTree::make( float d )

Node类型是class BinTree的成员。

做了:

BinTree::Node* BinTree::make( float d )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM