2D String Container Library Arrays

Hello everyone. I've taken a look around the forums and haven't been satisfied by some other posts regarding arrays - but I have learned some things.

I'm brand new to C++ but have a strong knowledge of Java syntax and OOP principles: so my questions are entirely syntactical.

I'm building my first program (I'll include 3 classes) and I would like to know how to:
1. Declare an empty 2D array container library of type string.
2. The syntax for said array in method headers (parameter for mutator).
3. The syntax for creating methods that return the 2D array (accessor).

My syntax so far supports only one dimension - also: can someone please take a look at my syntax for assigning values to the elements?

Thanks in advance.

Header:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  class Player
{
public:
	// Default constructor. 
	Player();

	// Overridden constructor. 
	Player(array<string, 9>);

	// Destructor.
	~Player();

	// 'gameState' Accessor method.
	array<string, 9> getGameState() const;

private:
	array<string,9> gameState;
};


.cpp file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Player::Player()
{
	for (size_t i = 0; i < 3; ++i)
	{
		for (size_t j = 0; j < 42; ++j)
		{
			gameState[i][j] = "x";
		}
	}
}

Player::~Player()
{

}

array<string, 9> Player::getGameState() const
{
	return gameState;
}


Injection point and logic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
	int main()
	{
		Player player;

		for(int i=0; i<3; i++)   
		{
			for(int j=0; j<3; j++)
			{
				cout << player[i][j];
			}
		}

		return 0;
	}

Topic archived. No new replies allowed.