943,736 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1064
  • C RSS
Dec 12th, 2006
0

question

Expand Post »
how can i get a program to include other cpp files??

like if i was on a tem for school and we spilt the work into smaall parts ca we just use ome kind of include function to put all the files together withotu copy-pasting:????
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shadowmoon is offline Offline
8 posts
since Oct 2006
Dec 12th, 2006
0

Re: question

That's usually done by linking multiple object files together.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Dec 12th, 2006
1

Re: question

What normally is done (assuming that only one of the code pieces has a main() ) is to compile each of the sourcefiles into a separate object file and then link them all into one program.

To simplify a compile you can create a makefile to do this, or create a project in IDE's like Visual Studio.

An example using g++
  1. g++ file1.cpp file2.cpp file3.cpp -o myprogram
Reputation Points: 62
Solved Threads: 10
Junior Poster
jim mcnamara is offline Offline
179 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Program works... now I need to create a function, HELP!
Next Thread in C Forum Timeline: Parameter lists for fucntion pointers??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC