2d Vectors in Class

Hello, I am currently trying to create a two d vector in my class. But it's giving me an error. I researched online and it says that I cannot initialize the dimensions of the vector inside the private part (haha) of my class and I have to initialize it in my constructor. Any idea how to do this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std; 
class OmokBoard{
public: 
    OmokBoard(){
    	
        int board_numbers = 0; 
        for(int col = 0; col < board_size; col++){
            for(int row = 0; row < board_size; row++){
                ostringstream convert; 
                convert << board_numbers;   
                num_board[row][col] = convert.str();
                board_numbers++; 
            }
        }
        for(int row = 0; row < board_size; row++){
            for(int col = 0; col < board_size; col++){
                sym_board[row][col] = " "; 
            }
        }
        board_size = 15;
    };
    
    OmokBoard(string, string){
    }
    void putPiece(int player_num, int position){ //playernum = 0,1   position = 0-50
        // sym_board
        // num_board
    
    }
    void printBoard(){    
        cout << endl;
        cout << "-"; 
        for (int j = 0; j < board_size; j++){
            cout << "----";
        }
        cout << "    ";
        cout << "-"; 
        for (int j = 0; j < board_size; j++){
            cout << "----";
        }
        cout << "    ";
        cout << endl;
       	for (int i = 0; i < board_size; i++){
            for (int j = 0; j < board_size; j++){
                cout << "|";
                cout.width(3);
                cout << left << num_board[i][j]; 
            }
            cout << "|" << "    "; 
            for (int j = 0; j < board_size; j++){
                cout << "|";
                cout.width(3);
                cout << left << sym_board[i][j];              
            }
            cout << "|" << endl;
            cout << "-"; 
            for (int j = 0; j < board_size; j++){
                cout << "----";
            }
            cout << "    "; 
            cout << "-"; 
            for (int j = 0; j < board_size; j++){
                cout << "----";
            }
            cout << endl; 
        }
    }
private: 
    int board_size;
    vector<vector<string> > sym_board(15, vector<string> (15));
	vector<vector<string> > num_board(15, vector<string> (15));
}; 

int main (){

    OmokBoard mainBoard; 
    mainBoard.printBoard();
    
    return 0; 
}
Topic archived. No new replies allowed.