[Solved] C++ curly brackets


To answer your first question. By doing an if statement in one line you are limited to one operation, so to speak.

if(ret != 0) return false;

Whilst using the curly brackets you are declaring a block with code operations.

if(ret != 0) {
     /* do other stuff here */
     return false;
}

There is no practical difference between using a one-liner and a block statement.

As to your second question please refer to my first line of code.

if(ret != 0) 
    return false;

is equivalent to;

if(ret != 0) return false;

The statement is delimited by using the semicolon to tell the compiler that the statement is finished, the space between is trivial.

solved C++ curly brackets