Prev: _in s and _out s ?
Next: MSI Serial Number Validation
From: Doug Harrison [MVP] on 2 May 2010 16:35 On Sat, 01 May 2010 17:04:02 -0700, Geoff <geoff(a)invalid.invalid> wrote: >What would you say about a practice like this? > >typedef enum {false, true} qboolean; > >qboolean funct(int arg) >{ > if (something) >/* do something */ > > return true; > > else > >/* do something else*/ > return false; >} That's one way you could do in C. However, I think I would use: typedef int boolean; enum { false, true }; This is consistent with the relational operators. That is, x == y yields an int equal to zero or one, and this is the closest thing to a genuine boolean result in C. The only reason I used an enum instead of #define to name the literals is so that the names would show up in the debugger. In pre-standard C++, I would have used const int for the literals. -- Doug Harrison Visual C++ MVP |