![]() |
.. (לתיקייה המכילה) | |
How should the dangling else problem be resolved? | |
The dangling else should be resolved as in C language. Meaning that: if (a) if (b) ... else ... is interpreted as: if (a) { if (b) ... else ... } |
Asuume the statement: | |
As explained in the precedence table, the relational operators are non-associative, and thus the following: bool a = 1 < 2 < 3; should raise a syntax error. |
Casting a byte to an int like so: | |
No. The only valid casting is from an enum type to int. |
Assume the following: | |
If JANUARY was never defined before, it should be errorUndef. If JANUARY was defined before (as a variable or as an enum value of another enum), it should be errorUndefEnumValue. |
Can an enum shadow another identifer? | |
No. Enum names and values are identifiers, and are not allowed to shadow or be shadowed by another identifier. For example, the following codes are not valid: void main() { int a1; enum a {a1, a2}; //invalid } -- void main() { enum a {a1, a2}; int a2; //invalid } |
Can we cast an enum value to an int? | |
Yes. For example, the following code is valid: enum A {a1, a2, a3}; void main() { int x = (int) a1; enum A y = a2; int z = (int) y; } |