开发者

managed c++ code doesn't find function implementation

I have 3 files:

  1. main ".h" file - contains implementation of a simple WinForm (managed c++)
  2. fold/file.h
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜