I'm a little confused on the Makefile dependencies for .cpp files. For example, say I have a file main.cpp that includes Point.h and Rectangle.h. I would think that the Makefile dependency line for main.o looks like:
main.o: main.cpp
But it seems most people would do:
main.o: main.cpp Point.h Rectangle.h
I don't understand why. Object files are created before linking, right? So when main.cpp is compiled to main.o, its references to Point and Rectangle functions are still unresolved references, in a way. Then, when making the final executable, the linker resolves the references with the machine code for Point and Rectangle. In other words, main.o doesn't really get impacted if I change Point.h or Rectangle.h. The final executable does depend on all three, but main.o does not. What is wrong with my thinking?