Does anyone have some ideas on how to write a functionality to interpret "y" and "n" as true and false assignments using the boolean statement? I am really confused with the boolean statement.
Well what I want to do is ask the user to enter names of past and present employees. Then I want to ask the user if he wants to see only the active employees only. If the user types "y", I want it to check and display each of the elements that is assigned true with. If the user says "n", then I want it to display all of them.
char input;
std::cin >> input;
if (input == 'y') {
// etc. etc. etc.
} elseif (input == 'n') {
// etc. etc. etc.
} else {
std::cerr << "That wasn't a valid input!\n";
}
You can also just store it in a boolean variable, like so:
1 2 3 4 5 6
char input;
std::cin >> input;
bool val = (input == 'y'); // true if 'y', false otherwise
// OR
bool val = (input != 'n'); // false if 'n', true otherwise