Computer Chess Club Archives


Search

Terms

Messages

Subject: TSCP / C++ question

Author: Dave Gomboc

Date: 22:01:00 05/11/99


I am taking a quick look at Tom's Simple Chess Program.  Here's a snippet:

/* the initial board state */

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
};

Now, imagine you are trying to do this in OO-style.  Say you have some class
State, and you want this to be inside of it.

So (in C++):

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
    };
};

This, however, does not compile.  (MSVC 6.0 reports error C2059, a syntax error
on the '{'.  Presumably, the array initialization isn't allowed.)

Ideally, this array would be declared static and const as well.
What is wrong here?  How can it be corrected?

Dave



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.