Jump to content
  • Advertisement
Sign in to follow this  
Marty666

proper architecture

This topic is 4830 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

Hi all, I've got a problem with the architecture of my projects. I usually have a main.cpp and a main.h. In the main.h i include all the other .h files, like model.h, math3d.h, patricle.h, etc. These .h files contain includes for their own .cpp file, but never main.h. When the project gets bigger it gets a mess and sometimes the compiler gives me trouble with double definitions, etc. What is the proper way to make lots of different .cpp files all with their own special functions and classes that sometimes use classes from different .cpp files? Thanx, Marty

Share this post


Link to post
Share on other sites
Advertisement
Okay well you should be prototyping your classes in a .h file and putting the actual definition in your .cpp file. Then to prevent double initilitzations on .h files simple do this


#ifndef _OBJLOADER_ALREADY_SEEN_
#define _OBJLOADER_ALREADY_SEEN_


replace OBJLOADER with the name of your cpp file, it should be some thing unique.

Then at the end of your file

#endif


This lets you include a .h file multiple times in diffrent files without running into compiler troubles.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!