Nested Switch Statement Ambiguous Overload for Operator

norahs63's Avatar, Join Date: Oct 2011
Light Poster
I'm pretty sure the ambiguous overload is being caused by having to use the same number to mean different things. I can't find a way to overcome it. It's supposed to be a phone call allocator: Press 1 for Raleigh office, then press 1 for new appointments, 2 for rescheduling an appointment and so on. First compiling error is "Ambiguous overload for Operator 1." Any help would be greatly appreciated.

Code:
#include <iostream>
using namespace std;
int main()

{

//Declare Variables
int menu_choice = 0;
int next_menu_choice = 0;
int Raleigh = 1;
int Durham = 2;
int ChapelHill = 3;

switch ( menu_choice )
{
    case 1:
    // Display the area menu
        cout << "Area Menu"
        << "1 = Raleigh"
        << "2 = Durham"
        << "3 = ChapelHill";

        cout << "Enter a menu choice: ";
        cin >> next_menu_choice;
        cout << endl;    
        
switch ( next_menu_choice )
{
       case '1':
       cout << "Make a new appointment in Raleigh";
       cin >> 1;
       cout << "Make a new appointment in Durham";
       cin >> 2;
       cout << "Make a new appointment in Chapel Hill";
       cin >> 3;
       endl;
       break;
        
        case '2':
        cout << "Reschedule an appointment in Raleigh";
        cin >> 1;
        cout << "Reschedule an appointment in Durham";
        cin >> 2;
        cout << "Reschedule an appointment in Chapel Hill";
        cin >> 3;
         endl;
        break;
        
        case '3':
        cout << "Billing questions in Raleigh";
        cin >> 1;
        cout << "Billing questions in Durham";
        cin >> 2;
        cout << "Billing questions in Chapel Hill";
        cin >> 3;
         endl;
        break;

        case '4':
        cout << "Talk to a nurse in Raleigh";
        cin >> 1;
        cout << "Talk to a nurse in Durham";
        cin >> 2;
        cout << "Talk to a nurse in Chapel Hill";
        cin >> 3;
         endl;
        break;

}      //end switch

cout << endl;
system("pause");
return 0;

} //end of main function

Last edited by shabbir; 9Oct2011 at 01:05.. Reason: Code blocks
norahs63's Avatar, Join Date: Oct 2011
Light Poster
I'm going to respond to my own post. This seems to be working well. Any suggestions?

Code:
#include <iostream>

using namespace std;

int main( ) {

int location= 0;
int activity= 0;

cout << "Press 1 for Raleigh office" << endl;
cout << "Press 2 for Durham office" << endl;
cout << "Press 3 for Chapel Hill office" << endl;

cout << "Enter Location: "<<endl;
cin >> location;

cout << "Press 1 for making a new appointment" << endl;
cout << "Press 2 for rescheduling an appointment" << endl;
cout << "Press 3 for billing questions" << endl;
cout << "Press 4 for talking to a nurse" << endl;

cout << "Enter activity: "<<endl;
cin >> activity;

switch (location) {
case 1: cout << "Raleigh: "; break;
case 2: cout << "Durham: "; break;
case 3: cout << "Chapel Hill: "; break;
}

switch (activity) {
case 1: cout << "making a new appointment" << endl; break;
case 2: cout << "rescheduling an appointment" << endl; break;
case 3: cout << "billing questions" << endl; break;
case 4: cout << "talking to a nurse" << endl; break;
}
cout << endl;
system("pause");
return 0;
}

Last edited by shabbir; 9Oct2011 at 01:05.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Please read the posting guidelines.
norahs63 like this