Multiple file c++

August 2, 2009 at 05:28:14
Specs: Windows XP, Athlon xp x2 64 5600 / 2gb
I'm currently in the middle of a c++ project(win32 console) that has grown to the point of being problematic to manage due to the size and it's set to be quite alot larger, possibly double or even more, than the ~600 lines already.

I'm trying to move some of the larger functions into separate source files and include them without much luck. For example I have a function that makes a console text editing field that works over an array.

Can anyone tell me(or point me to a good resource) that deals with how to do this properly? I know I need a .h file as well as the the function in it's own .cpp file but I don't know how to deal with dependencies. The functions are dependent on <string> <conio.h> <iostream> and possibly others.

I did quite a bit of searching but all the examples I found either gave more importance to why I should do this than how or didn't show how to resolve the dependencies.

I can post or upload the source code(all moved back into one source file for now) if anyone want to look at the half finished mess that it is at the moment(it does compile though), it is for dev-cpp

See More: Multiple file c++

Report •

August 2, 2009 at 09:02:59
I figured it out, I didn't need the .h file only the .cpp file and a forward declaration.

Report •

August 2, 2009 at 09:39:43
and a forward declaration.
That's pretty much what you'd have in the .H file. That and the #includes your declarations required.

Report •

August 2, 2009 at 09:49:10
Thanks, that makes things even neater, not having to put the #include <xx> in every file....

Report •

Related Solutions

Ask Question