困扰小弟我好久的链接有关问题error LNK2001: unresolved external symbol "public: _thiscall
困扰我好久的链接问题error LNK2001: unresolved external symbol "public: __thiscall
在头文件 "lei.h "中
class lei
{
public:
lei();
~lei();
public:
int a,b;
public:
int add();
};
在 "lei.cpp "中
#include "lei.h "
lei::lei()
{a=3;b=4;
}
int lei::add()
{
int c;
c=a+b;
return c;
}
在main.cpp中
#include "lei.h "
#include <stdio.h>
void main()
{
lei a;
int m;
m=a.add();
printf( "m=%d ",m);
}
编译后会有如下错误:
Linking...
main.obj : error LNK2001: unresolved external symbol "public: __thiscall lei::~lei(void) " (??1lei@@QAE@XZ)
Debug/trying.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
请各位大哥帮忙
------解决方案--------------------
没有实现析构函数:
//.cpp
lei::~lei()
{}
------解决方案--------------------
刚刚发现,FAQ中有关于LNK2001的详细讲解!^_^
在头文件 "lei.h "中
class lei
{
public:
lei();
~lei();
public:
int a,b;
public:
int add();
};
在 "lei.cpp "中
#include "lei.h "
lei::lei()
{a=3;b=4;
}
int lei::add()
{
int c;
c=a+b;
return c;
}
在main.cpp中
#include "lei.h "
#include <stdio.h>
void main()
{
lei a;
int m;
m=a.add();
printf( "m=%d ",m);
}
编译后会有如下错误:
Linking...
main.obj : error LNK2001: unresolved external symbol "public: __thiscall lei::~lei(void) " (??1lei@@QAE@XZ)
Debug/trying.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
请各位大哥帮忙
------解决方案--------------------
没有实现析构函数:
//.cpp
lei::~lei()
{}
------解决方案--------------------
刚刚发现,FAQ中有关于LNK2001的详细讲解!^_^