Pick random value from enum
Is it possible ?
enum example : Code:
enum Days(+=1) |
Re: Pick random value from enum
By default, enum values start from zero and increment for each. You can pick a random number from 0 to 6 and use it as a value for your enum, though you might have to manually tag/view_as to avoid warnings.
|
Re: Pick random value from enum
For enums of varying or long lengths, you may also add an element at the end of the list to represent the amount of elements before it to help with looping and such. Like:
PHP Code:
PHP Code:
|
Re: Pick random value from enum
Quote:
Code:
int day = view_as<Days>(GetRandomInt(Monday, Sunday)); warning 213: tag mismatch warning 213: tag mismatch |
Re: Pick random value from enum
Code:
enum Day |
Re: Pick random value from enum
Code:
enum Day |
All times are GMT -4. The time now is 03:04. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.