Simple tip until you're better at C++ such that you can ignore it and know exactly what went wrong: always use braces, even when the body of the if statement etc is only one statement. If you always do this, when the body of the if statement should be two statements, you won't make the mistake of having it apply to only the first statement.