Two confusing errors

Getting these errors in my .h file that I can't explain:


PrefixNode.h:15: error: field ‘next’ has incomplete type
PrefixNode.h:17: error: two or more data types in declaration of ‘root’


Here is my .h file:


#ifndef _PREFIXNODE_H_
#define _PREFIXNODE_H_
#include <iostream>
#include <list>
using namespace std;

class PrefixNode
{

private:
class stringPointer
{
private:
list <string> words;
PrefixNode next;
}
int* root;
stringPointer node;




public:
PrefixNode();
~PrefixNode();
int size();
};
#endif
You'll need to ensure that you're passing the PrefixNode type by reference so that it doesn't have to be completely constructed before it's referred to.
The compiler reports that you cannot define members of type PrefixNode until the definitiom of PrefixNode will be complete. The invalid statement is

PrefixNode next;

I think you was going to write

PrefixNode *next;



Topic archived. No new replies allowed.