我有以下文件:
interface.h
class Interface
{
...
};
Interface* CreateInterface();
实现.h
#include "interface.h"
class Impl: public Interface
{
...
};
实现.cpp
#include "impl.h"
SomeInterface* CreateInterface()
{
return new Impl;
}
...
主文件
#include "Interface.h"
int main()
{
CreateInterface();
}
最初我的项目看起来像这样。但是出于测试目的,所有文件现在都在同一个项目中。
编译时出现 LNK2019 错误,提示 CreateInterface 未解决。我正在使用 VS 2008 我不知道出了什么问题。