I have similar scenario as explained below:
I have one header file first.h
It has a function :
char* getName();
and associated cpp file first.cpp
having function definition
char* getName(){return "first";}
and the second header file second.h it has the function:
char* getName();
associated cpp file second.cpp
having function definition
char* getName(){return "second";}
Now there is a main()
function:
#include "first.h"
#include "second.h"
int main(){
return 0;
}
when I include those .h
files, compiler give an error at the function getName()
as it is conflicting.
How to get rid of this problem without changing .h files
C
orC++
? For C++ use this tutorial: tutorialspoint.com/cplusplus/cpp_namespaces.htm – Tobiastobie