There is no spoon.
.. or in this case there are no files. When your program is running, it is a process in memory -- all in one place. There are no "files" that should "see".
Perhaps this helps:
http://www.cplusplus.com/articles/Gw6AC542/
Lets try to make a simple example though.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
void foo ( int & x ) {
x += 42;
}
int main() {
int bar = 7;
int gaz = 0;
foo( gaz );
foo( bar );
std::cout << bar << ' ' << gaz <<'\n';
return 0;
}
|
If we look only at the function foo on lines 3-5, there is no sign that the function would see the objects bar and gaz. When main calls foo, the bar and gaz are used as parameters and at that point the foo does "see" those objects.
We could have the lines 3-5 in separate cpp-file. If so, that file clearly would no information whatsoever that there are foo and bar in some other file.
The main() would have to know about foo() though, in order to call it, just like we do introduce std::cout and std::ostream::operator<< with include before we can write line 14. We could either have the declaration of foo
void foo(int&);
in the file with main() or include a header that has that declaration. The latter is better, because then code in other cpp-files could call this same function.
Did this help to construct a different view to the issue?