I create a enum type with language codes like:
enum lang {
en,
it,
de,
asm,
or
}
but some codes are keywords (asm, or). How can I escape them, so that I
can use them like
lang::or or lang::asm ?
Thanks
Phil
Those are reserved words. You can not use them as identifiers. chose a
different form like Asm, asm_, l_asm, ...
Is there no other solution !? Because the language codes are defined in
the ISO 639, so I would like to use the defined
codes as a enum value. I wouldn't create a own value
Thx
Phil
<shrug> There probably is. Instead of introducing an identifier that
is illegal because it's a keyword, you could introduce a string literal...
> Because the language codes are defined in
> the ISO 639, so I would like to use the defined
> codes as a enum value. I wouldn't create a own value
<shrug again> I would like my variables to be named 'new', 'delete',
and 'for'. I can't, however. So?
V
--
I do not respond to top-posted replies, please don't ask
You can't. Note too that enum's don't introduce a new scope (at
least not in current C++), your enum introduces the keywords in
global scope.
The traditional solution to this is to use a simple prefix:
enum lang {
lang_en,
lang_it,
lang_de,
lang_asm,
lang_or
};
or something like that.
--
James Kanze
struct lang {
enum instruction {
EN,
IT,
DE,
ASM,
OR
};
};
?