When you execute a method there are to ways to leave:
1) You can explicitly use a
if (again != 'y')
PlayAgain = false;
is executed, the method exits at that point and no further code is executed.
2) If your code reaches the closing curly bracket for the method, it exits the method as it has no further statements to run:
This can prevent your code for even compiling as it doesn't specify a return value, so unless your method is declared as returning a
value, many compilers will issue an error on this.
And when your code exits the
method, your application ends as well.
So in your case, you need to provide some way to "go around again" in your method, or it will always close the app when the user has made a selection.
In this case, I'd suggest that you use a C++
do while Loop
] and use the existing
condition to exit that instead of