I'm running into a fairly annoying and somewhat inconsistent(at least as far as I know) bug involving a program where I have to declare an object for one class in another. This is done on three different occasions in the program in question and is only able to compile without error for the first instance of this. Every other instance is met with an error that states "[class name] does not name a type" (In case there's any confusion, it doesn't actually say "[class name]". It says the title of the class that I tried to declare an object for on the line where there is an error). Below is an example of what exactly I'm trying to do and am not succeeding at.
Main.cpp
1 2 3 4 5 6 7 8 9 10
#include "Loop.h"
int main(){
Loop loop;
loop.programLoop();
return 0;
}
Header file for the main class. Essentially just loops through the functions to be used. (Loop.h)
#include "Class1.h"
...
Class1::Class1(){
}
...
//some functions in original code set the values of variables in Class2 and use the return values of those variables
I can provide the full source code if my example doesn't provide enough information. However, since my code most likely exceeds the limit of the length of a post on this site, they will be shown via links to a site where the files are being stored.
An instance of Class1 has an instance of Class2 which has an instance of Class1 which has an instance of Class2 which has an instance of Class1 which has an instance of Class2...
I think I see where the problem is now, cire. The problem is that I need an instance in the scope of both classes in order for this to work. How could I do this?