I've met a problem when trying to compile chapter 8 drill 1. I did everything that the book tells me but I can't figure what's wrong
//my.h
extern int foo;
void print_foo();
void print(int);
//my.cpp
#include "my.h"
#include "../std_lib_facilities.h"
void print_foo(){
cout << foo;
}
void print(int i){
cout << i;
}
//use.cpp
#include "my.h"
int main(){
foo = 7;
print_foo();
print(99);
}
the error i got
use.cpp:4: undefined reference to `foo'
my.cpp:6: undefined reference to `foo'
All files are in the same directory.
Can anyone help please?