My problem is solved. It looks like the problem was related to the installation of code blocks but I was able to get the desired result after uninstalling and reinstalling codeBlocks. However the following are the details:
I am running codeBlocks 16.01 on ubuntu 16.04.9. The compiler I use is g++ version 5.4.0.
I have 3 files that I want to compile: main.cpp head.h head.cpp.
I had created a new empty project in codeblocks and then I had created these 3 files within codeblocks. I have also set the path in Setting->Build Options->Search Directories->Compiler->Add. However when I click the Build and Run button, codeblocks gives me the error that "Undefined reference to function 'sum(int, int)' ".