mercredi 31 octobre 2018

How to remove verbose sentences in peer if-else branch

Here I got three if-else branches in this program

int main(){
    if(condition == 1)
        functionA();
    if(condition == 2)
        functionB();
    if(condition == 3)
        functionA&B();
    }

Suppose that the value of condition only varies from 1 to 3. I wonder if there's way where condition = 3 so that I don't have to call functionA&B() but just use the former result of condition = 1 and condition = 2?

Aucun commentaire:

Enregistrer un commentaire