我正在使用UI表单使用VS 2013。 在MyForm.h中有一个代码
class A
{
public:
A();
~A();
private:
};
void b()
{
A var;
}
我收到了这些错误:
Error 2 error LNK2028: unresolved token (0A00000A) "public: __thiscall A::A(void)" (??0A@@$$FQAE@XZ) referenced in function "void __cdecl b(void)" Error 3 error LNK2028: unresolved token (0A00000B) "public: __thiscall A::~A(void)" (??1A@@$$FQAE@XZ) referenced in function "void __cdecl b(void)" Error 4 error LNK2019: unresolved external symbol "public: __thiscall A::A(void)" (??0A@@$$FQAE@XZ) referenced in function "void __cdecl b(void)" Error 5 error LNK2019: unresolved external symbol "public: __thiscall A::~A(void)" (??1A@@$$FQAE@XZ) referenced in function "void __cdecl b(void)"
我已经用Google搜索了大约两个小时,但仍然没有结果。
答案 0 :(得分:0)
你必须定义构造函数和析构函数,如:
class A{
public:
A();
~A();
private:
};
A::A(){
}
A::~A(){
}
void b()
{
A var;
}