Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

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;
}
like image 747
Freezerburn Avatar asked Feb 16 '10 08:02

Freezerburn


1 Answers

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 )
like image 175
Michael Burr Avatar answered Oct 25 '22 01:10

Michael Burr