I am new to C++ and I am porting over a Java project to C++.
Consider the following Java code, where Piece is a class representing a chess piece:
Piece[][] myPieces = new Piece[8][8];
It creates an array where all the entries are null.
How can I achieve the same thing in C++? I tried:
Piece* myPieces = new Piece[8][8];
But this will create an array with all the entries initialized with the default constructor.
Thanks
Edit: I want the C++ code to be efficient/elegant and I do not care nor wnant to copy paste from Java to C++. I am happy to heavily modify the code structure if needed.
Edit 2: The code is for chess programm, the size of the array will never change and performance is critical.
Piece** myPieces = new Piece*[8];, iterate over all 8 elements and create for each a new vector of 8 elements (ergo 64 total elements), or use a 1D vector and use indirect indexing..