I haven't seen much about this in tutorials or in my books, so I'm pretty sure I'm doing it wrong (or at least, not the best way).
I have my Main.cpp, then I've put all of my classes and larger functions in individual header files. Then I have a last header file named "Includes.h", which is the only file I actually include in Main.cpp. It looks something like this:
Main.cpp:
#include "Includes.h"
Includes.h:
1 2 3 4 5 6 7 8
|
#include <iostream>
#include <ctime>
#include <vector>
// Prototypes from Main.cpp here
#include "SomeClass.h"
#include "ClassReliesOnSomeClass.h"
|
In each header file I deleted everything that was generated and just treat it as a completely empty file. I don't know what that stuff does but apparently not much.
Here's a problem I've run into: In my current project I include SomeClass before including ClassReliesOnSomeClass, because, well, yeah. However, what do I do when I need SomeClass to rely on ClassReliesOnSomeClass?
In detail, I mean:
1 2 3 4 5
|
class Skill
{
public:
Actor GetActor(int i) const { return TheActor[i]; }
}
|
1 2 3 4 5
|
class Actor
{
public:
Skill GetSkill(int i) const { return TheSkill[i]; }
}
|
No matter which way around I include these classes, one will always be "not declared in this scope" because it hasn't been read yet.
How do I get around this, and structure my programs more efficiently? Thanks for the help.