This may just be me making a rookie mistake since I haven't programmed in a long, long time, but I'm getting some weird problems when I'm trying to divide my program into several source/header files.
The current program code looks a little bit something like this:
main.cpp
#include <cstdlib>
#include <iostream>
#include "functions.h"
using namespace std;
int main()
{
hello();
return 0;
}
functions.h
#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
void hello();
#endif // FUNCTIONS_H_INCLUDED
Hello.cpp
#include <cstdlib>
#include <iostream>
#include "functions.h"
using namespace std;
void hello()
{
cout << "Hello";
}
The error I am getting is: "Undefined reference to hello();" when it is called in the main.cpp file. If I include Hello.cpp in the header file, everything works fine and dandy, but that's obviously not the way to go. Am I missing something crucial here? All files are under the same project that I made in code::blocks. My SINCEREST apologies if I've either coded something wrong or this is as stated in the rules related to gnu cpp, however I thought all files under the project were supposed to be linked, whereas it does not seem this is the case?
Thanks!