Hi all!
I have a bit of a problem and Google isn't helping me
I'm trying to implement a namespace, let's call it test.
When i code my program like in the example below, it compiles, links and works fine.
Main.cpp
Code:
namespace test
{
void foo(void)
{
return;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
test::foo();
return 0;
}
When i try to move the namespace to separate .h/.cpp files, like the ones below, the linking fails.
Test.h
Code:
namespace test
{
void foo(void);
}
Test.cpp
Code:
void test::foo(void)
{
return;
}
Main.cpp
Code:
int _tmain(int argc, _TCHAR* argv[])
{
test::foo();
return 0;
}
Compiler output
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>Test.cpp
1>Main.cpp
1>Linking...
1>Main.obj : error LNK2001: unresolved external symbol "void __cdecl test::foo(void)" (?foo@test@@YAXXZ)
1>***\Visual Studio 2008\Projects\Test\Debug\Main.exe : fatal error LNK1120: 1 unresolved externals
What am i doing wrong? Any help is greatly appreciated!
Thanks!