Hi, Code::Blocks keeps giving me this error message whenever I try to compile:
'LinkListIterator' does not name a type
I've checked for spelling errors in my preprocessor identifiers and header files, and made sure to include the appropriate header files in the implementation files. But Im stumped and have no idea how to fix this. Any assistance will be appreciated. Thanks.
// LinkListIterator.h
#ifndef H_LinkListIterator
#define H_LinkListIterator
# include "UnorderedLinkList.h"
# include <iostream>
usingnamespace std;
class LinkListIterator
{
public:
LinkListIterator();
LinkListIterator(NodeType *ptr);
intoperator*(); // function to overload the dereferencing operator
LinkListIterator operator++();// overloads the preincrement operator
booloperator==(const LinkListIterator& right)const; // overloads the equal to operator
booloperator!=(const LinkListIterator& right)const; // overloads the not equal to operator
private:
NodeType *current; // pointer to point to the current node in the ll
};
#endif
Thank you helios and Alvaro (cpp-home.com). Forward declaration solved the problem. I was trying to use NodeType and LinkListIterator before providing their definitions.
1 2 3 4 5 6 7 8
// LinkListIterator.h
class NodeType;
class LinkListIterator
{
public:
...
1 2 3 4 5 6 7 8
// UnorderedLinkList.h
class LinkListIterator;
struct NodeType
{
int info;
...