Usually when you do e-terate,
enum Foo {
One,
Two,
Three,
Last
};
for ( int fooInt = One; fooInt != Last; fooInt++ )
{
Foo foo = static_cast<Foo>(fooInt);
// ...
}
It's the same way.
But this is not really an etherate
Two = 9
If you set a value separately, you cannot write it.
Therefore, when dealing with enum
, usually use the switch statement as follows, not iterate, and
switch ( foo )
{
case One:
// ..
break;
Case Two: // intentionally fall
case Three:
// ..
break;
case Four:
// ..
break;
default:
assert( ! "Invalid Foo enum value" );
break;
}
If you really want enum
to be literal, the only way is to put the value of enum
in vector
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.