Info :Compiling C:\tmp\lab2.cpp
Warn : lab2.cpp(56,16):Possible use of 'choice' before definition
Error: lab2.cpp(60,5):Type mismatch in redeclaration of 'mainProgram()'
Error: lab2.cpp(60,5):Declaration syntax error
Hi everone, I am new to C++, please help.
After I compile (using borland V5.02), I got these above prolem, please let me know what's wrong and this is my source code:
// Compiler: Borland C++ V5.02
//
// Program Description:
/////////////////////////////////////////////////////////////////////
// This program will provide the user with quotes from Walt Disney.//
/////////////////////////////////////////////////////////////////////
#include <iostream>
// function declarations...
void programDescription();
char mainMenu();
void mainProgram();
char choice();
/*
main entry point for the program.
*/
void main (void)
{
mainProgram();
}
/*
programDescription()
provides a description ()
Provides a description of the program to the user.
*/
void programDescription()
{
cout <<"This program will display famous quotes" << endl;
cout <<"make by Walt Disney. Topics are provided" << endl;
cout <<"in the menu box." << endl << endl ;
}
/*
mainMenu ()
Provides the main menu for the user to select from.
*/
char mainMenu()
{
char choice;
cout <<"Please select a topic to view quote:" <<endl <<endl;
cout <<"1. Challenge" << endl;
cout <<"2. Achievement" << endl;
cout <<"3. Overcoming Adversity" << endl;
cout <<"4. Ability" << endl;
cout <<"5. Persistence" << endl;
cout <<"6. Belief" << endl;
cout <<"E. Exit the program" << endl << endl;
cout <<"Your choice:" <<endl;
cin >> "choice";
return choice;
}
mainProgram ()
//Function that runs the entire program.
void mainProgram ()
{
char userChoice; //variable used to store menu choice..
int exit=0; //flag to quit the program...
void programDescription(); //describe the program to the user...
//loop that allows the user to continue or quit...
do
{
userchoice = mainMenu (); // show the menu...
switch (userchoice)
{
case '1':
cout << endl <<"It's kind of fun to do the impossible."<<endl;
break;
case '2':
cout << endl <<"The way to get started is to quit talking and begin doing."<<endl;
break;
case '3':
cout << endl <<"You may not realize it when it happen, but the kick in the teeth may be"<< endl;
cout << endl <<"the best thing in the world for you."<<endl;
break;
case '4':
cout << endl <<"If you can dream it, you can do it."<<endl;
break;
case '5':
cout << endl <<"Get a good idea and stay with it. Dog it, and work at it until it's done right."<<endl;
break;
case '6':
cout << endl <<"When you believe in a thing, believe in it all the way, implicitly and unquestionably."<<endl;
break;
case 'E'
case 'e'
exit = 1;
default:
cout << endl << "Sorry, that was not a valid choice." << endl << endl;
break;
}
}
}
While (exit !=1);
Thanks in advance.