You wrote this
for (int k = 0; k < 13; k++)
{
for (int j = 0; j< 1; j++)
{
for (int i = 0; i< 4; i++)
{
cabins[13][4][1] = (("b" "i" "i" "b")
Which would iterate across all the characters in the array, and then try to assign the entire array that slot, if it worked, or was valid C++.
I'm not sure what "(("b" "i" "i" "b")" is supposed to be, but you seem to have missed some C++ fundamentals. What you actually want is something more like
char cabins[13][4]; // only needs to be 2d.
void Ship::setArray()
{
cabins = {
{ 'b', 'i', 'i', 'b' },
{ 'b', 'i', 'i', 'b' },
...
};
}
[edit: I hit return early, working on the laptop, sorry]
This too would not work. If the array definition here is to be persistent, you'll need to store it somewhere.
Here's a complete single-compilation-unit example of how you might solve it:
#include <iostream>
#include <cstring> // for memcpy
class Ship {
public:
Ship() {}
char m_cabins[4][4];
void setArray();
};
void Ship::setArray() {
static const char defaultCabinLayout[4][4] = {
{ 'b', 'i', 'i', 'b' },
{ 'b', 'i', 'i', 'b' },
{ 'w', 'i', 'i', 'w' },
{ 'w', 'i', 'i', 'w' },
};
static_assert(sizeof(m_cabins) == sizeof(defaultCabinLayout), "defaultCabinLayout does not match m_cabins");
memcpy(m_cabins, defaultCabinLayout, sizeof(m_cabins));
}
int main() {
Ship s;
s.setArray();
std::cout << "cabins[0][0] = " << s.m_cabins[0][0] << std::endl;
}