Archived

This topic is now archived and is closed to further replies.

multiple files one compile

This topic is 5507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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..."

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

  
void dosomething(void)
{}


dosomething.h

  
extern void dosomething(void);


main.cpp

  
#include "dosomething.h"

int main(void)
{
dosomething();
return 0;
}

Share this post


Link to post
Share on other sites