error: expected initializer before 'foo'

Started by
1 comment, last by c4c0d3m0n 15 years, 7 months ago
I'm baffled.. I've tried googling, but this error message seems too generic for any good answers from there. My code: field.h
#ifndef _TTT_FIELD_H_
#define _TTT_FIELD_H_

#include <vector>



namespace ttt
{


enum symbol { empty = 0, x = 1, o = 2 };
enum coord { one = 0, two = 1, three = 2 };


class Field
{
  public:

    Field();

    void clear();

    symbol get( coord, coord ) const;
    void   set( coord, coord, symbol );


  private:

    std::vector<symbol> m_field;

}; // class Field


} // namespace ttt



#endif // _TTT_FIELD_H_
field.cpp
#include "field.h"

#include <vector>



ttt::Field::
Field()
    : m_field ( 9, empty )
{
}



void
ttt::Field::
clear()
{
    for ( int i = 0; i < 9; ++i )
      m_field = empty;
}



ttt::symbol
ttt::Field
get( ttt::coord x, ttt::coord y ) const
{
    return m_field[x+3*y];
}


void
ttt::Field
set( ttt::coord x, ttt::coord y, ttt::symbol s )
{
    m_field[x+3*y] = s;
}
The errors
field.cpp:25: error: expected initializer before ‘get’
field.cpp:33: error: expected initializer before ‘set’
Advertisement
voidttt::Field::set( ttt::coord x, ttt::coord y, ttt::symbol s ){    m_field[x+3*y] = s;}

same goes for the get.

Regards.
.... Sometimes I really wonder how I can miss out on stuff like this.... :( Thanks!

This topic is closed to new replies.

Advertisement