こんにちは、誰かがこれを正しく行う方法をアドバイスできれば。基本的に、ChessPiece インスタンスの 2 次元配列を保持する Board というクラス変数を作成しようとしています。
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
class ChessPiece
{
public:
char ToChar() { return '#'; };
};
class ChessBoard
{
int Size; //This means board is 8x8.
ChessPiece ** Board;
public:
ChessBoard();
int GetSize() { return Size; };
void PlotBoard();
};
ChessBoard::ChessBoard() {
Size = 8;
ChessPiece newBoard[Size][Size];
Board = newBoard; //Problem here!!! How do I make Board an 8x8 array of ChessPiece?
}
void ChessBoard::PlotBoard() {
int x, y;
for (x = 0; x < Size; x++) {
for (y = 0; y < Size; y++)
printf("%c", Board[x][y].ToChar());
}
}
int main()
{
// ChessBoard board;
// printf("%d", board.GetSize());
// board.PlotBoard();
ChessBoard * a = new ChessBoard();
return 0;
}
ここで本当に欠けているのはかなり基本的なことですが、それを理解できないようです。ありがとうございました!