I have the same book. While I did not do that particular exercise, I can see an important error.
Stroustrup says that "Note that use.cpp does NOT #include std_lib_facilities.h ..."
But your use.cpp above does have the lines #include <iostream> and usingnamespace std. I suspect that if you delete those 2 lines, your program will compile.
I hope someone else explains it better, but I think that you include the input/output library only once in a program. You have done that in the my.cpp file, so it is not necessary to do so again in the use.cpp file.
no no... i did exactly as he descriped, i just didn't write #include std_lib.... in the forum because it would confuse other people since they dont know whats in that folder. But in this case, only cout and cin is used... so i can just include iostream and i dont need std_lib_facilities.h
externint foo; is only declaration of variable foo It is not a definition of the corresponding object. To make a definition of the variable you should either initialize it in the same statement as for example
externint foo = 0;
Or include another statement which defines the object
externint foo;int foo;
So something like this.
use.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "my.h"
int foo;
int main()
{
foo = 7;
print_foo();
print(99);
char f; cin >> f; //keep window open
return 0;
}