The technical term for ‘multiple files’ would be translation units:
g++ file1.cpp file2.cpp -o program
Or you separate compilation and linking
g++ -c file1.cpp -o file1.o
g++ -c file2.cpp -o file2.o
# linking
g++ file1.o file2.o -o program
But that usually doesn’t make sense unless you have a larger project (e.g. with make
) and want to reduce build times.