Freezerburn
Freezerburn

Reputation: 1013

Expected constructor, destructor, or type conversion before '*' token

I honestly have no idea why this is happening. I checked, double-checked, and triple-checked curly braces, semicolons, moved constructors around, etc. and it still gives me this error.

Relevant code follows.

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

And 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;
}

Upvotes: 11

Views: 30064

Answers (1)

Michael Burr
Michael Burr

Reputation: 340198

Because on the line:

Node* BinTree::make( float d )

the type Node is a member of class BinTree.

Make it:

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

Upvotes: 21

Related Questions