hmm well this is what I did:
my.h file contains two function prototypes and an extern decleration to bring foo into scope.
//------------------------------------ my.h ------------------------------------------
extern int foo;
void print_foo();
void print(int);
//------------------------------------ my.h ------------------------------------------
my.cpp contains the implementation of the functions print_foo() and print(int).
//------------------------------------ my.cpp ------------------------------------------
#include "std_lib_facilities.h"
#include "my.h"
void print_foo()
{
cout << foo << endl;
}
void print(int i)
{
cout << i << endl;
}
//------------------------------------ my.cpp ------------------------------------------
use.cpp will have the main method
//------------------------------------ use.cpp -----------------------------------------
#include "my.h"
int main()
{
foo = 7;
print_foo();
print(99);
return 0;
}
//------------------------------------ use.cpp -----------------------------------------
You also need to declare foo (int foo;) somewhere, I chose to declare it on the last line of std_lib_facilities.h and then removed it after I verified it compiles and runs.
If you're on linux you can use this command to compile and run: g++ my.cpp use.cpp -o drill_1 ; ./drill_1