We have 2 cases (scenarios). In each case, we have 2 files : main.cpp
and file.cpp
Case 1
- main.cpp :
#include <iostream>
#include "file.cpp" // this line is what matters
int main () {...}
I compile and run by doing:
g++ main.cpp -o main && ./main
Case 2
- main.cpp :
#include <iostream>
void filefunc(int); // function declaration from file.cpp
int main () {...}
I compile and run by doing:
g++ -c main.cpp
g++ -c file.cpp
g++ main.o file.o -o main && ./main
How many translation units
do we have in each case ? is it :
- one for the first
- two for the second