Let me start off by saying I've read the gamedev article, and various articles online, and many C++ books, and none of them seem to actually answer the question. Here's my question:
When including multiple header files is there a good way to do it so that you don't run into issues where the compiler doesn't find things because the #include "blablah.h" is in the wrong order? Let me explain:
When I create a header file, it looks like this:
#ifndef _PARENTCLASS_H
#define _PARENTCLASS_H
class ParentClass
{
stuff
};
#endif //_PARENTCLASS_H
I also will have:
#ifndef _CHILDCLASS_H
#define _CHILDCLASS_H
class ChildClass : protected Parent
{
stuff
};
#endif //CHILDCLASS_H
Ok, now what I do is I will list them all in a library header file like so:
#ifndef _LIBRARY_H
#define _LIBRARY_H
//Include files
#include <iostream>
#include "ParentClass.h" //This doesnt work! I have to switch parent and childs
#include "ChildClass.h" //places in order for them to compile
#endif _LIBRARY_H
Last night I was ripping my hair out trying to figure why my button class didn't see my graphics class and it was all because of the order of my classes. Is there a way around having to worry about order of precedence? I would imagine there would be or else large programs would be a nightmare. I've looked at many online guides and have yet to find one that actually can give a good clear answer that works when I try it. Any help would be greatly appreciated. Thank you.
(I've also looked up pragma but I really don't understand how to use it. Maybe this is a solution?)