I see the point. Thats true. But still i've tried that in borland C++ builder X and when i tried to enumerat lik this
Code:
enum TerrainType
{
Plains=0,
Forest = 0,
Hills = -42,
Swamp = 666,
Water = 8,
Village = 1000
};
i've got error but not in enumeration but in loops using it.
and i've tried
Code:
enum flags
{
red = 1,
blue = 2,
green = 4,
black=8
}
than it's perfectly compiling it just like puting them in rising order according to value and than make correct step. Maybe builder X have some modified iostream library with overloaded ++ operator.
In any case thanks for help.no i see why it didn't work in VS and builder 6. And it sounds resonable And i wonder if i should use it or no in builder X nevertheless it's compiling and working correct.
p.s. I've also found a book in which i saw it. It's "C++ Pocket Refrence" published by O'Reilly.
there is such code sample:
Code:
enum SpectrumColor
{
Red,Orange,Yellow,Green,Blue,Indigo,Violet
};
for (SpectrumColor s=Red;s<=Violet;s++)
{
...
}