Ok, I have this scenario.
A class called a which includes windows.h.
#ifndef a.h
#define a.h
#include <windows.h>
class a
{
};
#endif
A class called b which includes windows.h.
#ifndef b.h
#define b.h
#include <windows.h>
class b
{
};
#endif
A main class as such.
#include "a.h"
#include "b.h"
MAIN STUFF
The point I’d like to clarify is the following.
Because I am importing both a and b into main, I am concerned that windows.h is being included twice. Is this so? If so, how to fix?
#windows.hshould be (read: is) clever enough that this is not a problem.They use “header guards” to guarantee safety of multiple inclusion within a TU, the same way you did in your files
a.handb.h(though you should really pick better names for those guards… oh how easily they can conflict at present!).To guarantee safety of multiple inclusion across TUs (not your scenario at the moment), they restrict themselves to only allowing declarations, not definitions, in header files. The rest will go in the library binaries that are part of your operating system. (And, in fact, aside from template/inline function definitions, you should always stray from defining things in headers).