Compiler complains about multiple definitions of func()
.
It seems have something to do with the code below residing in the header file, which is included by multiple other .cpp files. If func() is set to be inline, compilor would be happy. However, func() is expected to be executed only once... What are my options then?
namespace S
{
const LDS &func()
{
static LDS ret;
...
return ret;
}
}
inline LDS &operator<<(LDS &str_,stringType1 &data_)
{
str_ << S::func();
}
inline LDS &operator<<(LDS &str_,stringType2 &data_)
{
str_ << S::func();
}