Feb 22, 2012 at 8:41pm UTC
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
Feb 22, 2012 at 8:46pm UTC
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.
Feb 22, 2012 at 8:51pm UTC
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;