This one I've been working on for hours and cannot figure out. I created a method inside a pair of namespaces called format date:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
| #ifndef MXF_DATE_HPP
#define MXF_DATE_HPP
namespace mxf
{
namespace date
{
std::string formatDate(std::string formatStr)
{
...
}
}
}
#endif
|
When I try and call mxf::date::formatDate("..."); inside main I keep getting this error:
stdafx.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl mxf::date:: formatDate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (? formatDate@date@mxf@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V34@@Z) already defined in Sandbox.obj
C:\Documents and Settings\Owner\My Documents\Visual Studio 2010\Projects\f\Sandbox.exe : fatal error LNK1169: one or more multiply defined symbols found
I've verifyed over and over again that the hpp is included only once and that there are no similarly named functions. Here's my main():
1:
2:
3:
4:
5:
6:
7:
| int main(int argc, char* argv[])
{
string a;
a = mxf::date::formatDate("...");
return 0;
}
|
I'm hoping someone can tell me why I'm getting this error. I must have tried a 100 different things including renaming the function, renaming the namespace, removing a namespace, etc.
Thanks for the help!
Dan