ARTICLE AD BOX
I'm a CS student. I've learned that when you're linking files together you use a .h and a .cpp, like so:
// example.h #ifndef EXAMPLE_H #define EXAMPLE_H int addOne(int toAdd); #endif // example.cpp #include "example.h" int addOne(int toAdd){ return toAdd + 1; } // main.cpp #include "example.h" int main(){ int foo = 0; cout << addOne(foo) << endl; }My understanding of #include is that it takes the contents of the included file and prepends it to the contents of the current file. So my question is, why does #include "example.h" in main.cpp allow that file to access the function definition in example.cpp? example.cpp is never included in main.cpp, directly or through another file that is included.
