Keep in mind that the header file (.h) only contains the declaration of the function mycode::foo(), but the actual implementation of that function is in a separate source file (.cpp). Therefore, #include 'ing the header file only tells the compiler that the function exists, somewhere, but you still have to compile and link the actual implementation too! It is done like this, so that the declaration can be #include 'd at many different places (source codes files) of your project, but the implementation still only needs to exist at one place.
With GCC and similar compilers, you do something like: