Sorry about the late reply, I've been so emo lately. The plague of homework + busy work is really getting to me. I remember just last year when the end of the year came around nothing could stop my cheeriness, but it looks like this year is almost the exact opposite. I can't not be emo-core while I'm at school. (there now, heh)
Okay, first off, always use prototypes. Keep your prototypes and class definitions in .h files. So if you're program is called Oogama.cpp, you'd also have an Oogama.h which could look something like this:
Code: Select all
//Oogama.h
class VideoGame {
private:
char type[30];
int release_date;
char title[50];
public:
//Constuctor and all that crap
};
void Function1(int arg);
void Function2(int arg, char blarg);
Then, in your .cpp file you have the
definitions. Just remember: .h is for
declarations and .cpp/.c is for
definitions.
As for breaking it up into seperate files, I do that so religiously it isn't even funny. There isn't a rule, I just separate things into files that make sense to me. Something like a draw.cpp, main.cpp, input.cpp, particle.cpp layout is what I used on DCParticlez. Then every one of the .cpp's have their own corresponding .h to declare all the crap used by the functions and whatnot.
As far as actually including goes, I once thought it was okay to do just a #include "whatever.cpp"
As I've talked to people, that apparently is a very bad habbit. Not only that, but the only time I've ever gotten that to work is when I was building using the Pern project with VC++ for Dreamcast. All my SDL crap refuses to compile like that.
I need to go and look at the C++ book to see the "real" way to include other files. I doubt I'll get around to it before this summer though. Everything is one emo episode after another. All that I want to do nowadays is go home and either 1) kiss the ground and thank god I'm done with school for the day 2) Play video games.