samedi 18 novembre 2017

C++ curly brackets

I am wondering about some code i did see on the internet. I did try to google etc. but i didn't find an explanation that answered my question.

This is a example i coded.

bool exe() 
{

int ret = Geterror();//if error it returns something bigger than 0
if (ret != 0)
    return false;

ret = Geterror();//if error it returns something bigger than 0
if (ret != 0)
    return false;

return true; 
}

1) My first question is whats the different by using

if (ret != 0)
    return false;

and

if (ret != 0)
{ 
    return false;
}

2) I dont know if i think right or not, but is the line after if(ret != 0) the only line it going to run if ret is biger than 1? or does it has something to do with the posision or spacing? Sins ret = Geterror(); is going to run if ret is 0.

Aucun commentaire:

Enregistrer un commentaire