#Why is this getting skipped
17 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
Can you give us a file (or just text) of all of the inputs to your program that would reproduce the issue
Not your code's output.
Just your inputs
4
Chandler
Bing
5
this gets skipped ```cpp
void AddressBook::Quit() const{
std::cout << "Thanks for searching!\nGoodbye!\n";
}
all of these called in void AddressBook::Run()
Okay now that I know the issue, it's not from removing specifically, just any time you do another command first
oh yea ur right
looking at this part.
On the GetUserOption line, input gets set to 5.
break jumps to the end of the switch statement.
then the while(input != 5) check is run, and because it is false, the loop end.
case 4:
RemoveContact();
Menu();
input = GetUserOption();
break;
case 5:
Quit();
break;
default:
break;
}
}while(input != 5);
Quit() is never even reached
anyway, bedtime for me
Good luck
alr tty
i added a flag and it now works thank you
void AddressBook::Run(){
bool flag = true;
Menu();
int input = GetUserOption();
do{
switch (input)
{
case 1:
ShowAllContacts();
Menu();
input = GetUserOption();
break;
case 2:
SearchByName();
Menu();
input = GetUserOption();
break;
case 3:
SearchByDepartment();
Menu();
input = GetUserOption();
break;
case 4:
RemoveContact();
Menu();
input = GetUserOption();
break;
case 5:
Quit();
flag = false;
break;
default:
break;
}
}while(flag);
}
!solved