timbobsteve
Member
- Joined
- Oct 4, 2005
- Messages
- 301
Hi everyone,
A couple of questions:
Question 1: Code and File Stucture (*answered)
I am just getting back into C/C++ programming (gp2x style ) and I wanted to know your thoughts on a few things. While not gp2x specific it would be nice to know what others think.
Anyways.. as you all know splitting a project into multiple files is much easier than one monolithic main.cpp but I am sorta new to this, having only really used M$ based languages (C# and Delphi/Pascal) where multiple files never really came into it, or were handled by the IDE, how does everyone go about structuring things?
I have seen one idea, but I am not sure if its the right way to go. It entails creating a file called includes.h that basically acts as a pool for all includes throughout the program e.g.
then every other header file just includes includes.h at the beginning.
For one I can't see this working because system.h will have #include "includes.h" in it and it will in turn include system.h... and around we go... so I don't think this would work very well.
I am starting my first project and want to get it right before going to far into it only to discover that I have to restructure it all. How does everyone else go about splitting a project across multiple files?
I have been putting all header file information between #ifndef statements like so:
I have been trying to figure it out by myself for a few hours and I think I have gotten a little lost.... Would be nice to have someone help me find my bearings on this.
Question 2: To Objectify or Not?
I am currently writing a 2d engine for a game I want to make. I am using this as my learning project. For someone who has not really programmed anything major before, should I strive to objectify the engine code, or stick with my current procedural codebase?
On one hand it would force me to learn the ins and outs of OOP, on the other... well I am lazy ;D hahahhahaha.
What do you think for a first timer?
EDIT: Added new ? instead of creating new thread.
Thanks.
A couple of questions:
Question 1: Code and File Stucture (*answered)
I am just getting back into C/C++ programming (gp2x style ) and I wanted to know your thoughts on a few things. While not gp2x specific it would be nice to know what others think.
Anyways.. as you all know splitting a project into multiple files is much easier than one monolithic main.cpp but I am sorta new to this, having only really used M$ based languages (C# and Delphi/Pascal) where multiple files never really came into it, or were handled by the IDE, how does everyone go about structuring things?
I have seen one idea, but I am not sure if its the right way to go. It entails creating a file called includes.h that basically acts as a pool for all includes throughout the program e.g.
Code:
// Includes.h
#include "SDL.h"
#include "system.h"
#include "game.h"
#include "player.h"
#include "sound.h"
then every other header file just includes includes.h at the beginning.
For one I can't see this working because system.h will have #include "includes.h" in it and it will in turn include system.h... and around we go... so I don't think this would work very well.
I am starting my first project and want to get it right before going to far into it only to discover that I have to restructure it all. How does everyone else go about splitting a project across multiple files?
I have been putting all header file information between #ifndef statements like so:
Code:
// System.h
#ifndef SYSTEM_H
#define SYSTEM_H
prototypes here....
#endif
I have been trying to figure it out by myself for a few hours and I think I have gotten a little lost.... Would be nice to have someone help me find my bearings on this.
Question 2: To Objectify or Not?
I am currently writing a 2d engine for a game I want to make. I am using this as my learning project. For someone who has not really programmed anything major before, should I strive to objectify the engine code, or stick with my current procedural codebase?
On one hand it would force me to learn the ins and outs of OOP, on the other... well I am lazy ;D hahahhahaha.
What do you think for a first timer?
EDIT: Added new ? instead of creating new thread.
Thanks.