0

I'm working with VS 2013, using UI forms. In MyForm.h there is a code

class A
{
public:
    A();
    ~A();
private:
};

void b()
{
    A var;
}

I get those errors:

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)"

I've already googled for about two hours, but, still no result.

GSerg
  • 76,472
  • 17
  • 159
  • 346
Entrack
  • 51
  • 1
  • 1
  • 10

1 Answers1

0

You have to define the constructor and destructor like:

class A{
public:
    A();
    ~A();
private:
};
  A::A(){
}
  A::~A(){
}
void b()
{
  A var;
}
  • Thanks, but Columbo already solved it in the comments. Do you know, by the way, Can I use a "pair < Type, int>" If "Type" is the template ? compiler says error C2079: 'std::pair::first' uses undefined class 'Type' – Entrack Jan 04 '15 at 16:34
  • You have to write: template before define each function if you define it outside of the class. – János Simonyi Jan 04 '15 at 16:37
  • I mean I have a `template class List { private: list < pair < Type, int > > _list; int amount, max_amount, type; public: ` It says 'std::pair::first' uses undefined class 'Type' – Entrack Jan 04 '15 at 17:08
  • I dont know From this. Can you send me the full code somehow? – János Simonyi Jan 04 '15 at 17:17
  • I'm not sure. I just don't get can pair<> take an argument, if we've defined it as a template type (like template ). It doesn't work. Says: 'std::pair::first' uses undefined class 'Type' – Entrack Jan 04 '15 at 17:36
  • After you define a template you should be able to use anywhere i guess. I dont know, sorry. But make another question. – János Simonyi Jan 04 '15 at 17:39