![]() |
enum
How does it work?
I've used it before, but I can't remember how now. enum MODE{"FOLLOW","STAY","ATTACK"}; enum MODE{FOLLOW,STAY,ATTACK}; MODE.FOLLOW; this.action = MODE.FOLLOW; Help? I have no clue how it works. |
I'm not sure how Graal does it, but I think in C++ an enumeration is a word constant for numbers, in your example, follow would be 0, stay as 1, and attack as 2 and so on. But this isn't the format I've seen it in, I've never seen using mode.follow or the MODE at the front of the enumeration, so I could be very wrong XD
|
looks as if some array o.O
|
Quote:
It's used mostly so that you don't have to remember '2' means attack. You can just use MODE.ATTACK instead. Examples: PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
All hail Napo =p
|
Quote:
PHP Code:
PHP Code:
|
Yeah I've never done it with something in front of the definitions, I suppose it would be quite usefull
|
| All times are GMT +2. The time now is 05:46 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.