I want to use a function that from the "func.h" file in the Wireshark open source project. I need to use the funct() function in multiple .cpp files, but I get the a multiple definition error.
func.h:
#ifndef func_h
#define func_h
#include<string>
void *funct(char *cName)
{
std::string name = cName;
cName+= ".extension";
}
In the .cpp files I include the func.h:
#include "func.h"
And call the funct() function from 2 .cpp files:
funct("program");
What should I do so I don't get the multiple definition error? A workaround is to copy and paste the function defition in every .cpp file and change the function name, but this is ugly.
Many thanks.