Sign in to follow this  
Dennisvb

Different source files.

Recommended Posts

Dennisvb    160
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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Vortez    2714

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 :p

Share this post


Link to post
Share on other sites
Dennisvb    160


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 :p


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

Share this post


Link to post
Share on other sites
Dennisvb    160


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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this