Reputation:
What would be the value of Field.Format("%04d", ErrorCode) in the procedure below if the AErrorCode is ERR_NO_HEADER_RECORD_FOUND_ON_FILE?
Somewhere in a .h file:
enum AErrorCode
{
ERR_UNKNOWN_RECORD_TYPE_CODE = 5001,
ERR_NO_HEADER_RECORD_FOUND_ON_FILE,
ERR_DUPLICATE_HEADER_RECORD_FOUND,
ERR_THIRD_PARTY_LETTER_RECORD_HAS_A_ZERO_REFERRAL_AMOUNT = 5101,
ERR_CALL_OCA_UNKNOWN_PROBLEM = 5999
};
In some procedure:
void TADataset::SetErrorStatus(AErrorCode ErrorCode)
{
NDataString Field;
Field.Format("%04d", ErrorCode);
AckRecord.SetField("oca_error_stat", "E");
AckRecord.SetField("error_cd", Field);
}
Upvotes: 1
Views: 347
Reputation: 96849
ERR_NO_HEADER_RECORD_FOUND_ON_FILE == 5002
If you don't specify any value at all, it starts at 0
and increments the next element in the enum
. If you specify a value, then it starts incrementing starting by the next element. Unless you reset the counter again by specifying another value for a successor element.
Upvotes: 4
Reputation: 99535
According C++ Standard 7.2/1:
<...>If the first enumerator has no initializer, the value of the corresponding constant is zero. An enumerator-definition without an initializer gives the enumerator the value obtained by increasing the value of the previous enumerator by one.
It means that ERR_NO_HEADER_RECORD_FOUND_ON_FILE
equal to ERR_UNKNOWN_RECORD_TYPE_CODE+1
.
Upvotes: 2