is there a quick tut on how to work with multiple files all interlinked somehow, I''m trying to organize my small game up by seperating the functions into different files according to the class they belong to, and one file which stores all the classes.
But I get errors up the wazoo, saying this dosn''t have a type blah blah...
---
-Iron Eye
Cyrus Eye design _//_ My personal site _//_ Google
"Games usually keep me from making my own..."
multiple files one compile
what i''d do is make another file and call it "include.h"
#include all the files in your game in that one file, and then #include that file into all the files in your game.
example...
//Include.h
#include "MyFile.h"
#include "ThatFile.h"
//MyFile.h and ThatFile.h
#include "Include.h"
//Main.cpp
#include "Include.h"
that way, everything knows where everything else is.
#include all the files in your game in that one file, and then #include that file into all the files in your game.
example...
//Include.h
#include "MyFile.h"
#include "ThatFile.h"
//MyFile.h and ThatFile.h
#include "Include.h"
//Main.cpp
#include "Include.h"
that way, everything knows where everything else is.
You can use the extern key word to get to stuff in other files.
You should write a header file to filled with all the functions you want to use from the files and include it.
dosomething.cpp
dosomething.h
main.cpp
You should write a header file to filled with all the functions you want to use from the files and include it.
dosomething.cpp
void dosomething(void) {}
dosomething.h
extern void dosomething(void);
main.cpp
#include "dosomething.h"int main(void) { dosomething(); return 0; }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement