0

So I'm trying to use the Node class that I just wrote in my LinkedList class but I'm getting the error that:

Symbol 'Node' could not be resolved

in the code below.

#ifndef LINKEDLIST_H_
#define LINKEDLIST_H_

#include "Node.h"

template<class T>
class LinkedList {

    private:
        //Data Fields-----------------//
        Node<T> head;
        Node<T> tail;
};

#endif /* LINKEDLIST_H_ */

Node's declaration is below:

#ifndef NODE_H_
#define NODE_H_

template<class T>
class Node {

UPDATE:

So I still am having issues with my Node class being included in my LinkedList. But I discovered that by placing the two classes in one header file, I have no problems. So it must mean that the problem lies solely with the inclusion....which confuses me because that makes it seem like its some language based nuance that a beginner to C++ like me doesn't know about..

Ethan
  • 1,206
  • 3
  • 21
  • 39

2 Answers2

2

why do you have the semicolon after #include "Node.h" that's the problem.
Edit: Things you can do to troubleshoot:

  1. Inline the class definition
    i.e. replace the # include statement with the actual definition of the class (for testing only)
  2. Check your header guards (the ones like # ifndef LINKEDLIST_H_
    try renaming them or removing them altogether (again for testing only)
Ujjwal Singh
  • 4,908
  • 4
  • 37
  • 54
  • Have you tried inline-ing the included class definition instead of doing the #include? – Ujjwal Singh Aug 18 '12 at 17:05
  • Sure you can have an object as a member. I am asking you to only replace the incude statement with the actual definition of the class - for testing only. – Ujjwal Singh Aug 18 '12 at 18:12
  • ah, my mistake. let me give it a go Yes that fixed it.....So I guess it's not including it correctly...somehow – Ethan Aug 18 '12 at 18:14
  • any ideas as to what could be wrong with the include statement? – Ethan Aug 18 '12 at 19:07
0

So this just randomly started working for me...I don't know what the problem was but it works now... I'm using the CDT with eclipse, and it isn't the most stable thing for C++ development. SO my guess is that it has to do with that somehow....

Ethan
  • 1,206
  • 3
  • 21
  • 39