CodeBlock does't detect source file

I build 3 files main.cpp , head.h and head.cpp.


main.cpp===>>

#include <iostream>
#include "head.h"
using namespace std;

int main()
{
show();
return 0;
}


head.h===>>

#ifndef HEAD_H_INCLUDED
#define HEAD_H_INCLUDED

void show();

#endif // HEAD_H_INCLUDED


head.cpp===>

#include <iostream>
#include "head.h"
using std::cout;

void show()
{
cout<<"Hello world!!";
}
-----------------------------------------------------------------------------
simple program to illustrate my problem. Whenever i run this program i get an error saying
in function main undefine refernce to show()
--------------------------------------------------------------------------
any solution to configure my CodeBlock..
--------------------------------------------------------------------------
it is working only when i include head.cpp in head.h . and i don't want to do that .plzzz help
Last edited on
simple head.h is only declaration of function but body have to be in head.cpp so without include head.cpp function body is not available in main.cpp.

head.h--> only declaration of function
head.cpp--> include head.h and body of all fuction.
main.c-> include head.h + ......
in function main undefine refernce to show()


this error is telling you to define your function show().
you can define it in head.h or head.cpp
but i suggest to define it in head.cpp
> any solution to configure my CodeBlock..
Project -> Add files...
add head.cpp (and head.h if you didn't before)
thanx project - > add files works
Topic archived. No new replies allowed.