managed c++ code doesn't find function implementation
I have 3 files:
- main ".h" file - contains implementation of a simple WinForm (managed c++)
- fold/file.h
- fold/file.cpp
(file.h and file.cpp are not represent a class)
I have a function "func()" which its declaration is in fold/file.h开发者_StackOverflow, and its implementation is in fold/file.cpp.
There is include "fold/file.h" in main.h
When I call func() from main.h I get errors of: "Unresolved token" and "Unresolved external error". when I put the implementation of "func()" in fold/file.h there is no error.
What is the problem?
thanks!
when I put the implementation of "func()" in fold/file.h there is no error.
Are you compiling all the source files ? I suspect you are not because when you bring the definitions to the header file and include it in the main source file, pre-processor actually copies it to the main source file. So, while compiling and linking the main translation unit, compiler and linker can see both the declarations and the definitions respectively.
精彩评论