Archived

This topic is now archived and is closed to further replies.

Beowulf_

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

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites