The program I am working on deals with nested linked lists. I have a Olympics class that uses a linked list for events. Events have their own class with a linked list of contestants of a contestant class for each event.

I don't understand why I'm getting these compile errors:

379: error: `ListNode' has not been declared
380: error: ISO C++ forbids declaration of `node' with no type
: In function `Event* FindEventR(std::string, int*)':
386: error: `item' has not been declared
386: error: request for member of non-aggregate type before '->' token
388: error: `item' has not been declared
388: error: request for member of non-aggregate type before ';' token
391: error: `next' has not been declared
391: error: request for member of non-aggregate type before ')' token
: In function `Event* FindEvent(std::string)':
396: error: `head' undeclared (first use this function)
396: error: (Each undeclared identifier is reported only once for each function it appears in.)
: At global scope:
399: error: `ListNode' has not been declared
400: error: ISO C++ forbids declaration of `node' with no type
: In function `Event* AddSortedEventR(std::string, int*&)':
401: error: `item' has not been declared
401: error: request for member of non-aggregate type before ')' token
403: error: `ListNode' undeclared (first use this function)
403: error: `newPtr' undeclared (first use this function)
405: error: `head' undeclared (first use this function)
409: error: `next' has not been declared
409: error: request for member of non-aggregate type before ')' token

Everything is declared. I know its something wrong that I did, but I'm just not seeing it. Please any help would be appreciated. I'm sorry I'm attaching the code, but this program is more than just a few lines of code.

Recommended Answers

All 4 Replies

The problem is that you defined ListNode as a private member of Event class. So you can't use that structure outside ListNode. Make the structure public or move it outside any class. If you leave it as public member of Event class then you have to use Event::ListNode in order to access/reference it.

It doesn't matter that I declared the Olympic class as a friend to the Event class?

No it doesn't matter because the second parameter to FindEventR() is not a member of any class.

Thanks, I got it working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.