The answer depends, because contrary to Java, in C ++ you have different property semantics and object lifecycle management (these two go hand in hand).
If you want to model objects similar to java, you should write:
using PiecePtr = std::shared_ptr<Piece>; std::array<std::array<PiecePtr, 8>, 8> Pieces;
shared_ptr has similar semantics with a java object (pass it wherever it is guaranteed, and if there are links to it).
If you want to model the observed objects (i.e. the array does not own them), you should write:
using PiecePtr = Piece*; std::array<std::array<PiecePtr, 8>, 8> Pieces;
This ensures that when the Pieces object is destroyed, the actual parts themselves remain in memory.
If you want to model unique objects belonging to the Pieces array, you should use:
using PiecePtr = std::unique_ptr<Piece>; std::array<std::array<PiecePtr, 8>, 8> Pieces;
This ensures that when the Pieces object is destroyed, the actual parts themselves will also be destroyed.
source share