Question about enums
#1

Hey there, does an enumerator use memory ?
Or is it really just similar to a define
Reply
#2

-Wrong-
Reply
#3

No they aren't stored in memory

An enum is just an easy way to create a list of tagged / untagged constants
Reply
#4

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
No they aren't stored in memory

An enum is just an easy way to create a list of tagged / untagged constants
Actually that's wrong, all variables are stored in ram(Or in some cases in the CPU cache? dunno) , even the code is, how else would you have the speed that you need, obviously not by storing variables on hard drive.
Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Actually that's wrong, all variables are stored in ram(Or in some cases in the CPU cache? dunno) , even the code is, how else would you have the speed that you need, obviously not by storing variables on hard drive.
They aren't variables. Enumerator = iterator/list of consecutive constants. Enumerators don't store values. You can do pInfo:6, just like 6. But you can't give a tag to that specific index without an enumerator.

So you're the one that's wrong.
Reply
#6

but where is it stored if not in the memory? All information has to be stored somewhere not just variables, so explain pls

Or do u mean that they are replaced on compiletime?
Reply
#7

Enumerators are the same as macros. Variables with assigned enumerators are the ones storing things.

P.S. Double posting isn't allowed. Use the edit button.
Reply
#8

u didn't get my point i think ^^ what i meant was, that not only values are be stored (depending on how u define stored).
Reply
#9

no they are just constant values and not variables .They are not saved in the memory
Reply
#10

There get replaced from the pre-compiler to constants..for example:

PHP код:
//Before pre-compiler
enum x
{
    
a,
    
b
};
new 
test[x];
test[a] = 5;
test[b] = 6;
//After pre-compiler
new test[2];
test[0] = 5;
test[1] = 6
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)