Tuesday, March 22, 2011

C++, Delphi, Enumerations, Enum, switch, case,

In Borland Delphi, the way to check if a parameter of an enum type has a particular value is:
Code:
enum TGridDrawState {Grids_3, gdFocused, gdFixed}; . . . procedure SomeProcedure(Value: Int;ARect: TRect; AState: TGridDrawState); . . . if (gdFixed in AState) then . . . etc...

The C++ equivalent is:

Code:
void __fastcall SomeMethod(int Value, TRect Rect, TGridDrawState AState) { . . . if (AState.Contains(gdFixed)) { . . . } . . . etc....
Took me far too much time searching through the code and the internet to dig this up.

No comments:

Post a Comment