В C ++ вы можете определить тип 2D-массива следующим образом (вам нужен современный компилятор C ++):
#include <array>
typedef std::array<std::array<Piece, 8>, 8> board_t;
Если ваш компилятор не поддерживает std::array
, вы можете использовать boost::array
вместо:
#include <boost/array.hpp>
typedef boost::array<boost::array<Piece, 8>, 8> board_t;
Теперь вы можете использовать тип выше. Как я вижу, вам нужно скопировать объект, на который указывает указатель:
board_t* oldpointer = new board_t;
// do some with oldpointer
// now make a copy of the instance of the object oldpointer points to
// using copy-constructor
board_t* newpointer = new board_t( *oldpointer );
// now newpointer points to the newly created independent copy
// do more
// clean up
delete oldpointer;
// do more with newpointer
// clean up
delete newpointer;