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?

the0roamer
  • 650
  • 4
  • 9
  • 21

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
  • 119,862
  • 22
  • 374
  • 446
  • yes I had forgot to include Archive:: in front of the function definition, thank you @Andy Prowl – the0roamer 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