Why am I getting these errors?
#1

Why doesn't the following code work? How can I fix this?

Код:
#define MAX_FACTIONS 10
enum _FactionData
{
        Weapons[47]
};

new FactionData[MAX_FACTIONS][_FactionData];
main()
{
        FactionData[0][Weapons[0]] = 1;
}
Errors:

error 028: invalid subscript (not an array or too many subscripts): "Weapons"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

EDIT: The fix seems to be to replace FactionData[0][Weapons[0]] = 1; with FactionData[0][Weapons][0] = 1; Can anyone explain why it isn't the way I originally coded it?
Reply
#2

Because it's an enum.

And when you uses an Array in an enum it adds a new dimension in your array.

Thats why you have to do:

PHP код:
FactionData[0][Weapons][0] = 1
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Because it's an enum.

And when you uses an Array in an enum it adds a new dimension in your array.

Thats why you have to do:

PHP код:
FactionData[0][Weapons][0] = 1
Ah okay I see, thanks for the explanation.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)