Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Nested Switch Statement Ambiguous Overload for Operator (http://www.go4expert.com/forums/nested-switch-statement-ambiguous-t26874/)

norahs63 8Oct2011 19:31

Nested Switch Statement Ambiguous Overload for Operator
 
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. :confused:

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


norahs63 9Oct2011 00:09

Re: Nested Switch Statement Ambiguous Overload for Operator
 
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;
}


xpi0t0s 10Oct2011 00:48

Re: Nested Switch Statement Ambiguous Overload for Operator
 
Please read the posting guidelines.


All times are GMT +5.5. The time now is 05:05.