294                                                     10. 

void sums(world w, int sm [ ] ) ;

void living::sums(world w, int sm[])
{

int i , j ;

sm[EMPTY] = sm[GRASS] = sm[RABBIT] = sm[FOX] = 0;

for (i = -1; i <= 1; ++i)
for ( j = -1; j <= 1; ++j)

sm[w[row + i][column +j] -> who()]++;

        -  sums ().
        -
     -.   -
    ,    .   -
    ,     
,         .  -
    sums ().     
(Conway).

   :

//   ()
class fox : public living {
public:

fox(int r, int c, int a = 0) : age(a)
{ row = r; column = c; }

state who() { return FOX; }  //   

living* next(world w) ;

protected:

int age;                      //
};

//   ()
class rabbit : public living {
public:

rabbit(int r, int c, int a = 0) : age(a)
{ row = r; column = c; }

state who() { return RABBIT; }

living* next(world w) ;

protected:

int age;

};

//    ()
class grass : public living {
public:

grass(int r, int c) { row = r; column = c; }

state who() {return GRASS;}