1

The following are in main.cpp file:

string password;
string temp_password;

archiveObj.checkPassword(password,temp_password);

and the declaration of "checkPassword" is in the derived class "Archive" as below:

string checkPassword(string,string);

but when I run the code in Visual Studio Express 2010, I get the following error:

Error 1 error LNK2001: unresolved external symbol "public: class std::basic_string,class std::allocator > __thiscall Archive::checkPassword(class std::basic_string,class std::allocator > &,class std::basic_string,class std::allocator > &)" (?checkPassword@Archive@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV23@0@Z) C:\Users\HP\documents\visual studio 2010\Projects\Room def\Room def\Main.obj

Can anyone help me figure out the problem please?

ehsan0x
  • 660
  • 5
  • 10
  • 24

1 Answers1

2

The message you are getting comes from the linker, and the linker is complaining because it was unable to find the object code for checkPassword().

Perhaps you forgot to provide a definition for that function (you have a declaration, but you are not showing whether the function is also defined), or you forgot to link in the .cpp file where the definition of checkPassword() is given.

Andy Prowl
  • 124,023
  • 23
  • 387
  • 451
  • yes I had forgot to include Archive:: in front of the function definition, thank you @Andy Prowl – ehsan0x May 22 '13 at 19:03
  • @EhsanMamakani: Thought so ;) If this answered your question, please consider marking the answer as accepted when you will be allowed :) – Andy Prowl May 22 '13 at 19:04