HELP! (How do multiple CPP files work???)

Started by
1 comment, last by Beowulf_ 21 years, 5 months ago
Ok, this is a really stupid/easy question, so easy, in fact, that no-one explains it. I''ll start with the problem. I''m coding my first game, sort of a hack n'' slash clone, very heavy on the classes. For practaice. However, with all these classes, I don''t want to stash them all in one cpp file, because it would be a mess. I THINK the way to do this, would be to give each class it''s own cpp file. However, it seems (as i tested with a simple function) that one cpp file cannot access the contents of another. What do I do? Include one cpp file in another? For some reason that seems wrong and perverse to me. Someone want to clue me in?
Advertisement
Kylotan has kindly provided us with an answer: http://www.gamedev.net/reference/programming/features/orgfiles/
just to add some info:

multiple .cpp files work under a Project. If you don''t have any project files, you have to have one. In Visual C++, it''s called Project/Workspace, in VC.NET it''s called Project/Solution. I don''t know in other compilers.

When you start a project, you will be given blank projects (considering you use VC++, not using any wizards). You insert all (new/existing) files as many as you want into the project, and start coding. When you compile the project, all .cpp files will be compiled automatically. Each .cpp file will be treated as a separate object file, thus they somehow don''t communicate well to each other. To solve this, use header files.

Don''t #include any .cpp files. Only #include .h files. It''s the .h files that provides the "bridge" between your .cpp files.

My compiler generates one error message: "does not compile."

This topic is closed to new replies.

Advertisement