Hey guys, I have a problem with inheriting classes and I've read this book I have in front of me for the last half an hour and still cannot get it to work.
I have attached the entire project here since I've only just started.
Any help with this would be very appreciated.
The errors:
It means that you're doing something in graphics.h that requires knowledge of the full definition of struct Game, but you're only including the forward definition. Typical examples are passing an instance by value, or accessing a member. Either include the full definition, or better yet, move those parts that need the internals into grahpics.c (if this is possible).
I have it including a forward declaration of the class Game and I get those errors. I've attached all of the source code on the first post to show how I'm doing it to save posting parts of code.
Added a video https://www.facebook.com/video/video.php?v=121471064624660
In include/graphics.h
class Graphics : public Game {/*...*/};
You didn't include 'include/game.h' there, so it has no idea how to inherit the Graphics class from the Game class. A forward declaration will not work there.
In include/game.h
class Game { public: Game(); ~Game(); void Run(); void Error( const char* format, ... ); Graphics* gfx; private: };
You didn't include 'include/graphics.h' or 'include/fwd/graphics.h' there, so it has no idea what a Graphics* is.
As an aside, making separate headers for forward declarations is silly. If you need a forward declaration in some other header, just write it there.
I included stdafx.h that includes those :/ I'll give it a shot in a sec 
Edit: Nope that didn't work either. I think there is a problem with my compiler.
Append: Fixed by creating an Error class named CError and setting classes that need the error functions to work.
Why would anyone think to look in stdafx.h? I thought that was some kind of MSVC thing...
Only include what actually needs to be included, don't just mash everything into a single header and then include that everywhere.
I see the problem now. stdafx.h includes both include/game.h and include/graphics.h, both of which include stdafx.h. Circular inclusion bad...
So game.h looks like :
So game.h tries to include itself, but it's header guards prevent it from actually being included. The next thing that happens is that include/graphics.h is included, but class Game hasn't been completely declared yet, resulting in an invalid use of incomplete type struct Game.
Something similar happens in graphics.h.
Only include what is completely necessary for each file.
If you need a forward declaration, do it in the header that needs it.
You should only include in stdafx.h standard and 3rd party library headers, not headers from your project.
The point of stdafx.h is that it's used to generate precompiled headers, that is, the compiler will only parse everything inside stdafx.h the first time you build your project (and after that, only when one of those files changes). That extremely increases build times, as long as nothing inside stdafx.h changes (that's why you shouldn't include there project headers).
append:
Why would anyone think to look in stdafx.h? I thought that was some kind of MSVC thing...
It's just a standard header as any other in the project. It's just the usual name given to the header that will be used for generating the precompiled header (but you can ignore this, it's just a build optimization, it doesn't change any semantics).
I got it all working now guys. Thanks for your help 
I shall defiantly be keeping that in mind from now on