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 errorsfield.cpp:25: error: expected initializer before ‘get’
field.cpp:33: error: expected initializer before ‘set’