Author: Bo Persson
Date: 10:57:16 11/15/01
Go up one level in this thread
On November 15, 2001 at 13:40:04, Poschmann wrote:
>On November 15, 2001 at 13:18:12, Robert Pope wrote:
>
>>I was looking at crafty's chess.h, and noticed that Bob uses a typedef when
>>creating enums:
>>
>>typedef enum {none=0, pawn=1, knight=2,
>> king=3, bishop=5, rook=6, queen=7} PIECE;
>
>You define a variable with:
>PIECE piece;
>
>>
>>My program, still in the early stages, does it without, and seems fine so far:
>>
>>enum pieces {none=0, pawn=1, knight=2, bishop=3,
>> rook=4, queen=5, king=6};
>
>You define a variable with:
>enum pieces piece;
>
>The first solution is a little bit shorter and better readable. That is the only
>difference. The compiler-created program code is the same in both cases.
Another difference is that Bob's code is fine Standard C, while the latter is
more like C++, where you can even skip the enum altogether for the variables and
and write just:
pieces piece;
Bo Persson
bop2@telia.com
>>
>>Are these declarations equivalent, are they different structures for different
>>purposes, or is mine just waiting to blow up in my face once I move on to other
>>sections?
>>
>>Thanks,
>>Rob
>
>Ralf Poschmann
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.