if...else...finally? question about style
I'm looking for a way to do this in a more elegant way - if possible.
Code:
/*bool a,b,c maybe passed in by parameters*/
bool entered= false;
if (a) {
... code for section a....
entered= true;
}
else if (b) {
...code for section b....
entered= true;
}
else if (c) {
...code for section c....
entered= true;
}
if (entered) {
... common code for all sections ...
}
I use the above solution quite frequently in my code, but it's doesn't really look like good style to me. I know I could check for (a || b || c) in a surrounding if check, but that would double the number of checks for the compiler. Is there some better way to do this? Maybe a completely different approach? I feel like I'm missing something...