source: tests/enum_tests/typedIntEnum.cfa

Last change on this file was eb7586e, checked in by JiadaL <j82liang@…>, 13 days ago
  1. Change return value of typed Enum in null context: they now return the position. Therefore, printf with enumeration value will no longer be supported. 2. sout now will return the enumeration value. So sout | enumValue will print what we expect. 3. Provide enum.hfa, which contains traits that related to enum. 4. Implement functions declare in enum.hfa for enum types, so enum type fulfill the traits. Known defeat: error if we use the enum traits on enum types. They work but c compiler gives an warning
  • Property mode set to 100644
File size: 428 bytes
Line 
1#include <fstream.hfa>
2
3enum(int) IntEnum {
4    zero,
5    one,
6    thousand = 1000,
7    thousand_one,
8    two_thousand = 2000,
9    two_thousand_one,
10    two_thousand_two
11};
12
13int main() {
14    sout | "0=" | zero;
15    sout | "1=" | one;
16    sout | "1000=" | thousand;
17    sout | "1001=" | thousand_one;
18    sout | "2000=" | two_thousand;
19    sout | "2001=" | two_thousand_one;
20    sout | "2002=" | two_thousand_two;
21    return 0;
22}
Note: See TracBrowser for help on using the repository browser.