Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8442939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:58:53+00:00 2026-06-10T08:58:53+00:00

I’m making a Tic-tac-toe game and i have a board class which contains 9

  • 0

I’m making a Tic-tac-toe game and i have a board class which contains 9 instances of tile class and does something with them. At first i used a C array to create those instances Tile board[MAX_TILES] and everything works fine with them. However i want to use vectors instead since they’re safer so i tried the same with vectors std::vector<Tile> board(MAX_TILES); but instead i’m getting a bunch of errors in my .cpp file and 2 errors in my .h file.

I’m not used to vectors yet since i’ve been taught to use C style arrays by our college professors. What am i doing wrong?

Here is my Board.h and the errors, if you need the .cpp i’ll provide:

#ifndef BOARD_H
#define BOARD_H

#include <SFML\Window.hpp>
#include <vector>

#include "tile.h"

#define MAX_TILES 9

enum Position
{
    TOP_LEFT        = 0,
    TOP_MIDDLE      = 1,
    TOP_RIGHT       = 2,
    MIDDLE_LEFT     = 3,
    MIDDLE_MIDDLE   = 4,
    MIDDLE_RIGHT    = 5,
    BOTTOM_LEFT     = 6,
    BOTTOM_MIDDLE   = 7,
    BOTTOM_RIGHT    = 8
};

class Board
{
private:
    std::vector<Tile> board(MAX_TILES);
    //Tile board[MAX_TILES];
    void positionTiles();
public:
    //Constructors
    Board();
    Board( TileState tileState );
    //Methods
    void clearBoard();
    void drawBoard(sf::RenderWindow& window);

};

#endif

the errors 1 and 2 are from .h and others are from .cpp:

Error   1   error C2059: syntax error : 'constant'  
Error   2   error C2059: syntax error : 'constant'  
Error   3   error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   4   error C2228: left of '.setTilePosition' must have class/struct/union    
Error   5   error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   6   error C2228: left of '.setTilePosition' must have class/struct/union    
Error   7   error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   8   error C2228: left of '.setTilePosition' must have class/struct/unio
Error   9   error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   10  error C2228: left of '.setTilePosition' must have class/struct/union    
Error   11  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   12  error C2228: left of '.setTilePosition' must have class/struct/union    
Error   13  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   14  error C2228: left of '.setTilePosition' must have class/struct/union    
Error   15  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   16  error C2228: left of '.setTilePosition' must have class/struct/union    
Error   17  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   18  error C2228: left of '.setTilePosition' must have class/struct/union    
Error   19  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   20  error C2228: left of '.setTilePosition' must have class/struct/union    
Error   21  error C3867: 'Board::board': function call missing argument list; use '&Board::board' to create a pointer to member 
Error   22  error C2109: subscript requires array or pointer type   29
Error   23  error C2228: left of '.setTileState' must have class/struct/union   
Error   24  error C3867: 'Board::board': function call missing argument list; use '&Board::board' to create a pointer to member 
Error   25  error C2109: subscript requires array or pointer type   
Error   26  error C2228: left of '.setTileState' must have class/struct/union   
Error   27  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   28  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   29  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)       45
Error   30  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   31  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   32  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   33  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   34  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   35  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   36  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   37  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)       49
Error   38  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   39  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   40  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   41  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   42  error C2228: left of '.getTileSprite' must have class/struct/union  
Error   43  error C2677: binary '[' : no global operator found which takes type 'Position' (or there is no acceptable conversion)   
Error   44  error C2228: left of '.getTileSprite' must have class/struct/union  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:58:55+00:00Added an answer on June 10, 2026 at 8:58 am

    You cannot do this in C++03.

    std::vector<Tile> board(MAX_TILES);
    

    You should use this in c-tor.

    Board():board(MAX_TILES)
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.