Created
May 1, 2013 02:42
-
-
Save swillits/5493431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.c | |
// | |
#include <stdio.h> | |
#include "Game.h" | |
int main(int argc, const char * argv[]) | |
{ | |
Game * game = NewGame(); | |
RunGame(game); | |
return 0; | |
} | |
// | |
// Game.h | |
// | |
#ifndef Forward_Game_h | |
#define Forward_Game_h | |
typedef struct Game Game; | |
Game * NewGame(); | |
void RunGame(Game * game); | |
#endif | |
// | |
// Game.c | |
// | |
#include <string.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include "Game.h" | |
#include "Manager.h" | |
struct Game { | |
int score; | |
Manager * manager; | |
}; | |
Game * NewGame() | |
{ | |
Game * game = (Game *)calloc(sizeof(Game), 1); | |
game->manager = NewManager(); | |
return game; | |
} | |
void RunGame(Game * game) | |
{ | |
UseManager(game->manager); | |
printf("Game over.\n"); | |
} | |
// | |
// Manager.h | |
// | |
#ifndef Forward_Manager_h | |
#define Forward_Manager_h | |
typedef struct Manager Manager; | |
Manager * NewManager(); | |
void UseManager(Manager * manager); | |
#endif | |
// | |
// Manager.c | |
// | |
#include <string.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include "Manager.h" | |
#include "Game.h" | |
struct Manager { | |
int stuff; | |
}; | |
Manager * NewManager() | |
{ | |
return (Manager *)calloc(sizeof(Manager), 1); | |
} | |
void UseManager(Manager * manager) | |
{ | |
printf("Used manager.\n"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment