Monday, May 24, 2010

How do i split my c++ code into various source files?

im using eclipse with CDT. my program works right now as a single source file. i want to split into various, so is easier to keep coding. i have problems with includes and stuff. what is the right way to do this? i didnt find any tutorial for this.. thanks

How do i split my c++ code into various source files?
Separate out the functions, according to what makes sense to you, into additional .cpp files. You can right-click on the project name to add the new files. Write declarations for those functions in a header file or files (e.g. filename "mystuff.h"). Then in whichever .cpp files use those functions, put #include "mystuff.h" at the top. Name the .h file or files in a way organized to relate to the .cpp files whose functions they declare. Think about how you would most conveniently re-use the functions later.

floral centerpieces

No comments:

Post a Comment