struct piece {
    piece(){}
    piece(int spacs[][3])
    {
        spaces = spacs;
    }
    int spaces[][3];
};

/home/myname/Programming/C++/blokus1/game.hpp|11|error: incompatible types in assignment of ‘int (*)[3]’ to ‘int [0][3]'

How can this be fixed?

Welcome to C (not C++) where arrays and pointers are almost synonymous. Consider an STL vector<tuple<int,int,int> > instead?

Edited 6 Years Ago by griswolf: n/a

NathanOliver is almost right, but I at least do like to distinguish "define" and "declare". A declaration is about type whereas a definition is about value. So I would say you could declare it as int* spaces[3] . Since this is C++, you do have access to all the STL classes which in my opinion make both programming and learning to program easier, so I continue to recommend that frenchie4111 consider using a std::vector unless his teacher says not.

I do agreee that vectors do have advantages but this is still c++. It is still usefull to know how to do these things because there are times when you would be better of with a 2d array instead of a 2d vector.

Edited 6 Years Ago by NathanOliver: n/a

Of course some C++ programmers will need to understand how to deal with pointers to multi dimensional arrays, but I suspect many student programmers never will need such skills, so I'm really talking more about the order that concepts are introduced to new C++ programmers. I started from C, so I had my trial by fire before I ever heard of C++. Perhaps because of that, I may appreciate more than most how much easier it is now than it was before there was an STL in the standard.

My own take, which is certainly not universal, is that student programmers will make much better progress if we introduce string, vector, iteration, etc earlier rather than later; and allow them to concentrate at first on what it means to do programming, rather than how to overcome what will seem to them like obscure and esoteric errors.

Edited 6 Years Ago by griswolf: n/a

I got it to work using std::vector< boost::tuple<int,int,int> > thanks for the help.

This question has already been answered. Start a new discussion instead.