vendredi 2 septembre 2016

Best way to check if integer does not equal 0 in c++

I currently have 2 methods to do the above. Which one is better, and why?

Method 1

int i = 1;
if (i != 0)
{
    //....
}

Method 2 (Same variable)

if (i)
{
    //...
}

Which one of these is better to check for a nuber being 0, and why?

Aucun commentaire:

Enregistrer un commentaire