I actually don't prototype classes, just functions. I have no idea why I put that, must not have been paying enough attentionGyroVorbis wrote:You do realize that while it is definitely good practice to keep header includes from headers to a minimal, simple class/function prototyping often isn't enough? Consider class A inheriting from class B. Class A REQUIRES Class B to be included, so that the compiler knows how much space to allocate in memory for an instance of class A.eatcomics wrote:Don't include headers in headers, they're bad...
compiling with SDL issues
Moderator: Coders of Rage
Re: compiling with SDL issues
-
- Chaos Rift Junior
- Posts: 345
- Joined: Tue Jan 12, 2010 7:23 pm
- Favorite Gaming Platforms: PC - Windows 7
- Programming Language of Choice: c++;haxe
- Contact:
Re: compiling with SDL issues
That's perfectly fine and valid. =]X Abstract X wrote:What I meant was that something like the following would not compile until you include <string> in the .cpp file (and it would have to be included before including "A.h"). Which is why you should include <string> inside the header instead, unless you can get away with a forward declaration instead. Am I wrong about this?GyroVorbis wrote:A header file has absolutely no dependence on a .cpp file whatsoever (unless you're #including a .cpp from within the header). This doesn't make any sense.X Abstract X wrote: A header file should be able to compile with it's cpp file left empty.
A.hA.cppCode: Select all
#ifndef A_H #define A_H class A { public: void doShit(const std::string& myString); }; #endif
Code: Select all
#include "A.h"