|
|
christian.bau wrote:
> On Mar 28, 5:48 pm, aark...@xxxxxxxxx wrote:
>
>> why are constant integer expressions required in case labels of the
>> switch statement? what would be the impact of allowing general
>> integer expressions instead of constant integer expressions? discuss
>> both user convenience and implementation aspects?
>
> Consider
>
> switch (i) {
> case f (): printf ("f"); break;
> case g (): printf ("g"); break;
> }
>
> Discuss under user convenience, implementation, and general mental
> health aspects.
No different to:
if (i==f())
printf("f");
else if (i==g())
printf("g");
which is perfectly legal. It's a question of freedom of expression.
--
Bart
|
|