error LNK2001: unresolved external symbol?该怎么处理
error LNK2001: unresolved external symbol???
我写了一个a.h文件:
class a{
public:
int set();
};
然后在a.cpp中实现set函数
#include "a.h"
int a::set()
{
return 123;
}
我新建一个工程,把a.h和a.cpp文件放到当前目录下,在工程中包含a.h,并调用set函数:
#include <iostream.h>
#include "a.h"
void main()
{
class a ts;
int s= ts.set();
cout<<s<<endl;
}
报错:
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall a::set(void)" (?set@a@@QAEHXZ)
Debug/test5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
如何解决???
------解决方案--------------------
首先
没必要用
我写了一个a.h文件:
class a{
public:
int set();
};
然后在a.cpp中实现set函数
#include "a.h"
int a::set()
{
return 123;
}
我新建一个工程,把a.h和a.cpp文件放到当前目录下,在工程中包含a.h,并调用set函数:
#include <iostream.h>
#include "a.h"
void main()
{
class a ts;
int s= ts.set();
cout<<s<<endl;
}
报错:
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall a::set(void)" (?set@a@@QAEHXZ)
Debug/test5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
如何解决???
------解决方案--------------------
首先
没必要用
- C/C++ code
class a ts;
------解决方案--------------------
在工程中包含a.h
很明显没在工程里加入a.cpp
------解决方案--------------------