mercredi 18 décembre 2019

C++ using IF convention

Which way is considered right?

bool func(){
  if(a){
    ..
    if(b){
      ..
      if(c){
        return true;
      }
    }
  }

  return false;
}

or

bool func(){
  if(!a) return false;
  ..
  if(!b) return false;
  ..
  if(!c) return false;

  return true;
}

I know that there is no difference in sense, but there may be a difference in performance and readability. So which way is way-to-do?

Aucun commentaire:

Enregistrer un commentaire