enum {
ValidationLoginFailed=2000,
ValidationSessionTokenE开发者_开发问答xpired=2001,
ValidationSessionTokenInvalid=2002,
ValidationEmailNotFound=2003
ValidationSucccesMIN=ValidationLoginFailed,
ValidationSucccesMAX=ValidationEmailNotFound,
ValdationValidSuccessCode=9999,
ValdationInvalidCode=10000
};
typedef int ValidationStatusCodes;
please help me out.
In your code, ValidationStatusCodes
means int
, not your anonymous enum
type. So they aren't actually connected in any way.
However, since your enum
contains int
values, you could say that there's some sort of relation. You can pass the names of the enumerated values and they will be considered of the int
or ValidationStatusCodes
type.
By the way, Apple does something similar to what you do, except they typedef
their collective names to NSInteger
or NSUInteger
instead of int
or uint
. See this question for an example.
With all that said, a more common practice is to typedef
your custom type name directly to the anonymous enum
, like this:
typedef enum {
ValidationLoginFailed = 2000,
ValidationSessionTokenExpired = 2001,
ValidationSessionTokenInvalid = 2002,
ValidationEmailNotFound = 2003
ValidationSuccessMIN = ValidationLoginFailed,
ValidationSuccessMAX = ValidationEmailNotFound,
ValdationValidSuccessCode = 9999,
ValdationInvalidCode = 10000
} ValidationStatusCodes;
精彩评论