#include "stdafx.h"
#include <iostream>
#include <string>
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
void DisplayMenu();
{
/* Function: Displays on the screen the selectin of addition, subtraction and exit.
Precondition:
Postcondition:
*/
cout << "Please choose from one of the following: ";
cout << endl;
cout << "1. Get Arabic number";
cout << endl;
cout << "2. Get Roman numeral";
cout << endl;
cout << "3. Convert from Arabic to Roman";
cout << endl;
cout << "4. Convert from Roman to Arabic";
cout << endl;
cout << "5. Print Arabic number";
cout << endl;
cout << "6. Print Roman Numberal";
cout << endl;
cout << "7. Quit";
cout << endl;
}
int GetCommand();
{
/* Function: Gets the choice from menu
Preconditon:
Postcondition:
*/
int userChoice;
cout << endl;
cout << "Please type in your choice: ";
cin >> userChoice;
return userChoice;
}
void RunChoice();
{
/* Function: Run the command the user selected.
Precondition:
Postcondition:
*/
int choice;
choice = GetCommand();
if(choice==1){
cout << "You chose #1";
//run "Get Arabic Number"
}
else {
if (choice==2){
//run "Get Roman Numeral"
}
else {
if (choice==3){
//run "Convert from Arabic to Roman"
}
else {
if (choice==4) {
//run "Convert from Roman to Arabic"
}
else {
if (choice==5) {
//run "Print Arabic Number"
}
else {
if (choice==6) {
//run "Print Roman Numeral"
}
else {
if (choice==7) {
//run "Quit"
}
}
}
}
}
}
}
}
return 0;
}
I have this code here and I wanted to retrieve the user input from the GetCommand function over to RunChoice function. However when I try to compile the code it gives me an error Roman Numerals.obj : error LNK2019: unresolved external symbol "int __cdecl GetCommand(void)" (?GetCommand@@YAHXZ) referenced in function _wmain.
Sorry to bump this, but any help would be greatly appreciated. Been working on this for a couple hours now and have been googling frantically, but still can't figure it out! Lol.
Thanks for the reply. Okay so how would I approach this? I first off want to create a display menu function which shows the user what to pick. Then I need to create a function that gets the command from the user. Then another that runs the command.
I think I have the basic code correct, but I don't know how to use the variable I got from GetCommand() to RunCommand().
Another error I ran into by moving the functions out of the main() is error C2447: '{' : missing function header (old-style formal list)
Remove the ; from the end of your function definitions' first lines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int GetCommand()//; <- these guys are only needed in function headers, i.e. if you aren't supplying the body yet
{
/* Function: Gets the choice from menu
Preconditon:
Postcondition:
*/
int userChoice;
cout << endl;
cout << "Please type in your choice: ";
cin >> userChoice;
return userChoice;
}