Jump to content
  • Advertisement
Sign in to follow this  
c4c0d3m0n

error: expected initializer before 'foo'

This topic is 3561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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’

Share this post


Link to post
Share on other sites
Advertisement

void
ttt::Field::set( ttt::coord x, ttt::coord y, ttt::symbol s )
{
m_field[x+3*y] = s;
}

same goes for the get.

Regards.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!