|
-
January 27th, 2008, 10:48 AM
#1
Splitting up code?
I was wondering, is it possible to split up your code into seperate files, like cpp files, that contained the functions? If so, would you have to "include" them or would they just be linked in?
-
January 27th, 2008, 10:50 AM
#2
Re: Splitting up code?
Yes. Typically, you would place class definitions and function prototypes into headers, then implement the classes and functions in source files. You would include the relevant headers in the respective source files.
-
January 27th, 2008, 11:14 AM
#3
-
January 27th, 2008, 11:56 AM
#4
Re: Splitting up code?
To take LaserLight's statements a bit further.
Typically there is one header (.h/.hpp) and one implementation (.cpp) per class.
However for large classes it is also possible to divide the functions among multiple .cpp files so they are easier to track (or for other reasons like some of the functions being created by a code generator.
It is generally a bad idea (and difficult) to split a header into multiple files, although it is physically possible via includes in the middle of the class definition.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|