• FEATURED

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

## Different source files.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Dennisvb  Members

Posted 01 March 2013 - 02:44 PM

Hello,

I want to have my Init, Update, Draw and CleanUp functions all in different source files, so when the game gets larger I don't end up with long compiling times. Do I need to put every function in a different class, or do I create a class called for example Game and define the functions in different source files like this: Game::Init() etc.?
Thanks,
Have a nice day!

Posted 01 March 2013 - 03:06 PM

You can put the function bodies for class member functions in separate source files as long as they all include the class definition (which would be in the header file).

Not sure if it will improve compile times though and it will probably prevent some optimisations (splitting the functions across different files, usually the optimiser only optimises each file individually), unless you use compile time linking, which slows down the compilation a lot...

Edited by Paradigm Shifter, 01 March 2013 - 03:07 PM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #3Vortez  Members

Posted 01 March 2013 - 10:43 PM

It should't matter if you put those functions all in the same file, in fact it will be faster since you'll only need to compile one file instead of four when doing a full rebuild or make change to more than one functions. Using four files for those function will probably add complexity to your project with no noticable benifits whatsoever, unless you're compiling with a 486

### #4Dennisvb  Members

Posted 02 March 2013 - 12:48 AM

It should't matter if you put those functions all in the same file, in fact it will be faster since you'll only need to compile one file instead of four when doing a full rebuild or make change to more than one functions. Using four files for those function will probably add complexity to your project with no noticable benifits whatsoever, unless you're compiling with a 486

Ha, thanks. I thought it would be quicker, but I will put those functions all in one class in one file ;).

### #5Vortez  Members

Posted 02 March 2013 - 10:39 PM

Still, it's a good idea to put different class in different files, but for single functions, i would not recomend it.

### #6Dennisvb  Members

Posted 03 March 2013 - 12:25 AM

Still, it's a good idea to put different class in different files, but for single functions, i would not recomend it.

That is what I do now.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.