Author: Charles L. Williams
Date: 15:36:52 05/13/99
Go up one level in this thread
On May 12, 1999 at 01:47:14, David Blackman wrote:
>On May 12, 1999 at 01:01:00, Dave Gomboc wrote:
>
>>class State {
>>
>>public:
>> // stuff
>>
>>protected:
>> // more stuff
>>
>> int init_color[64] = {
>> 1, 1, 1, 1, 1, 1, 1, 1,
>> 1, 1, 1, 1, 1, 1, 1, 1,
>> 6, 6, 6, 6, 6, 6, 6, 6,
>> 6, 6, 6, 6, 6, 6, 6, 6,
>> 6, 6, 6, 6, 6, 6, 6, 6,
>> 6, 6, 6, 6, 6, 6, 6, 6,
>> 0, 0, 0, 0, 0, 0, 0, 0,
>> 0, 0, 0, 0, 0, 0, 0, 0
>> };
>>};
>>Dave
>
>Probably for your purposes it should be static. I think that makes it easier to
>compile without errors too. Also here, in the class definition it should just be
>static int init_color[64];
>Put the initialiser somehere else, outside the class definition. Should be
>something like
>
>static int State::init_color[64] = {
> 1,1,1,1,1,1,1, /* more numbers */ };
>
>At least i hope this is it. I didn't actually test this. const is optional here,
>but does seem sensible.
>
>I think the reason for the errors you got has something to do with OO
>philosophy. You aren't supposed to initialise object fields in the class
>definition. You're supposed to do it in the constructor. But class fields (ie.
>statics) should be initialised just once in the program, so you can get away
>with it for statics.
It works, except leave the static off outside of the class definition, where the
array is being initialized.
Chuck
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.