I am not totally familiar with all the different syntax constructs for doing something like this - I started with the SWITCH version
First question - those BREAK; statements aren't really needed - or maybe it just isn't a good practice to do RETURN's from CASE statements?Code:bool isPunc(int &cc) { switch (cc) { case cDash: return true; break; case cPeriod: return true; break; case cSpace: return true; break; default: return false; break; } }
At any rate - I guess I could have just declare a BOOL and set it as TRUE in each CASE - then simply return that BOOL...
But then I thought of doing it this way.
Opinions?Code:bool isPunc(int &cc) { if (cc == cDash) { return true; } else if (cc == cPeriod) { return true; } else if (cc == cSpace) { return true; } else { return false; } }
Better methods??
Other C++ syntax that I'm not aware of that is better suited for this type of simple check??


Reply With Quote