When to use NULL

Getting these errors from compiler, any clue what they mean?


WordCompleter.cpp: In constructor ‘WordCompleter::WordCompleter()’:
WordCompleter.cpp:6: error: no match for ‘operator=’ in ‘((WordCompleter*)this)->WordCompleter::root = 0’
PrefixNode.h:8: note: candidates are: PrefixNode& PrefixNode::operator=(const PrefixNode&)

I'm just assigning a member variable to NULL, and it's a pointer. I'm not sure what the errors mean. Some enlightenment?

Post the actual code that is causing this and the declaration of the member in question.
WordCompleter.cpp:


#include "WordCompleter.h"
using namespace std;

WordCompleter :: WordCompleter()
{
root=NULL;
}


PrefixNode.h:

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

class PrefixNode
{

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

stringPointer node[26];




public:
PrefixNode();
~PrefixNode();
int size();
};
#endif

You should to show the definition of WordCompleter. But in any case your error is that there is no an overloaded assignement operator that can be used in the statement

root=NULL;

I just want to set the Root to NULL.
What is "root"?
A prefixnode pointer
Your compiler doesn't think it is. Maybe you should recheck the type.
Topic archived. No new replies allowed.