Pointer to a Linked List

Hello,
I keep getting the following error when ever I try to create a pointer to a linked list from another class:

C++ forbids declaration of 'ContentsOfFile' with no type


How do I create a pointer to a linked list, from another class?

For example, this is what I tried but it did not work:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Files
{
      public:
             ContentsOfFile *Contents; // pointer to linked list where
                                       // contents of file can be found (??)
             Files();
             Files *next; 
                          
};

// Linked list where contents of file is stored
class ContentsOfFile
{
      public:
             string fileContents;     
};


Any assistence will be greatly appreciated
Last edited on
You at least have to forward declare ContentsOfFile before using it.

Either move the declaration of ContentsOfFile before Files, or put

class ContentsOfFile;

before class Files to forward declare it.
Topic archived. No new replies allowed.