multiple files one compile

Started by
3 comments, last by Iron Eye 21 years, 5 months ago
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..."
---
ConPong _//_ Google _//_ Chaos Forge - quick and easy file hosting for developers

"Games usually keep me from making my own..."
-Me
---



find your elementat mutedfaith.com.
Advertisement
http://www.gamedev.net/reference/programming/features/orgfiles/
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.
Programmers of the world, UNTIE!
Matt, that method kind of scares me, just think about debugging...just my 2 cents
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
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; }  
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement