enum Number{ZERO, ONE, TWO, THREE, FOUR, FIVE, TEN=10, ELEVEN};The actual values assigned to each of the items in the braces starts with zero for the first and increments sequentially. A specific value can be assigned to one of the "values" as shown. When this is done the subsequent items are given values sequentially from that value. Thus the defined values for the enum Number will be ZERO=0, ONE=1, TWO=2, THREE=3, FOUR=4, FIVE=5, TEN=10, and ELEVEN=11.
Number num = ZERO;Now the variable num can be used in code. Note: that it can only be assigned one of the values defined for it.
if(num == ZERO) NUM = ONE; switch(num) { case ZERO : // Do something break; case ONE : // Do something break; case TWO : // Do something break; case THREE : // Do something break; case FOUR : // Do something break; }
int iVar; // Create an int variable int& iRef = iVar; // Create a referencd and set it to iVarThere are, however, some rules you have to follow in creating reference variables.
![]() |
![]() |
![]() |
![]() |