In Stroustrup\'s The C++ Programming Language: Special Edition (3rd Ed), Stroustrup writes that the declaration and initialization of variables in the conditionals
To complement the other folks' good answers, you can always limit the scope of the variable by braces:
{ const int readResult = read(socket); if(readResult < 0) { // handle error } else if(readResult > 0) { // handle input } else { return true; } }