I am confused of how to use nested "include"s, since I wrote some and g++ gave me several errors saying that I used undefined classes and " error: forward declaration of". However, I already declare those classes in other files. My real codes are quite long but it basically looks like the following. I wonder whether I placed some definition where I am not supposed to and there is any better ways to it?
Thanks,
/////File1.h/////
#ifndef FILE1_H
#define FILE1_H
class A;
class B;
Oh Actually I meant for a, b, c, x and y to be pointers. They all will form some kinds of multi-dimension linked lists. Like for example "b" of an A instance will point to an instance of B. Then, each instance of B contains *next which points to another instance of B and so on.
Also, each instance of B contains c that points to an instance of C. Also, each instance of C contains *next which points to another instance of C and so on.
For each instance of C, x will just point to an instance of A. (not form a linked list for x)
I know it might look weird but I just happened did it. Now I have two header files like above. Each of them contains the other header like file1.h includes file2.h and file2.h also includes file1.h.
I am wonder whether these "include"s are valid?