Hi, I get this error when trying to compile this simple code.
1>------ Build started: Project: Yes or No Program, Configuration: Debug Win32 ------
1> Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol "char __cdecl askYesNo2(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?askYesNo2@@YADV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>c:\users\Admin\documents\visual studio 2012\Projects\Yes or No Program\Debug\Yes or No Program.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It doesn't make sense to me as I have included everything as instructed, and the code isn't the problem. Apperently I'm not including something but I have no idea what?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
// Yes or No
// Demonstrates return values and parameters
#include <iostream>
#include <string>
using namespace std;
char askYesNo1();
char askYesNo2(string question);
int main()
{
char answer1 = askYesNo1();
cout << "Thanks for answering: " << answer1 << "\n\n";
char answer2 = askYesNo2("Do you wish to save your game?");
cout << "Thanks for answering: " << answer2 << "\n\n";
return 0;
}
char askYesNo1()
{
char response1;
do
{
cout << "Please enter 'y' or 'n' : ";
cin >> response1;
}while(response1 != 'y' && response1 != 'n');
return response1;
}
char askYesNo2()
{
char response2;
do
{
cout << "Please enter 'y' or 'n' :";
cin >> response2;
}while(response2 != 'y' && response2 != 'n');
return response2;
}
|