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:????

Recommended Answers

All 2 Replies

That's usually done by linking multiple object files together.

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++

g++  file1.cpp file2.cpp file3.cpp -o myprogram
commented: Good help - ~s.o.s~ +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.