First off, I have a main header file called Library.h. It includes all the other header files and main files that need to be included. It generally looks something like this.
Code: Select all
#ifndef LIBRARY_H
#define LIBRARY_H
#include "SDL.h"
#include <stdio.h>
#include "Levels.h"
#include "Globals.h"
// etc etc etc
#endif
Code: Select all
#ifndef LEVELS_H
#define LEVELS_H
// stuff here
#endif
That's generally the structure of my projects.
One other thing I want to ask is about classes. Some people define their class prototypes in a header file and then the classes member functions in a cpp file of the same name, e.g.
Test.h
Code: Select all
class Test
{
private:
int lol;
public:
Test();
~Test();
int WutIsTehLolz();
};
Code: Select all
Test::Test()
{
lol = 1;
}
Test::~Test()
{
}
int Test::WutIsTehLolz()
{
return lol;
}
Test.h
Code: Select all
class Test
{
private:
int lol;
public:
Test();
~Test();
int WutIsTehLolz();
};
Test::Test()
{
lol = 1;
}
Test::~Test()
{
}
int Test::WutIsTehLolz()
{
return lol;
}