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
When i try to move the namespace to separate .h/.cpp files, like the ones below, the linking fails.Code:namespace test { void foo(void) { return; } } int _tmain(int argc, _TCHAR* argv[]) { test::foo(); return 0; }
Test.h
Test.cppCode:namespace test { void foo(void); }
Main.cppCode:void test::foo(void) { return; }
Compiler outputCode:int _tmain(int argc, _TCHAR* argv[]) { test::foo(); return 0; }
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!



LinkBack URL
About LinkBacks




