ref void init_board (ref int side, ref char[][] board) //make empty symbol chessboard
{
const char black = ' ';
const char white = 0xB0;
board[0][0] = ' ';
for (int i = 1; i <= side; i++)
{
board[i][0] = 0x30 + i; //Setting nums; "Error: Cannot convert int to char"
board[0][i] = 0x40 + i; //Setting letters; same here
for (int j = 1; j <= side; j++)
board[i][j] = (i+j)%2 == 0 ? black : white; //making black-white board
}
}
我想做一個簡單的象徵棋盤。如何正確設置數字和字母取決於或行數/列數? board[i][0] = 0x30 + i;
(或0x40的)工作在C++,但不是在D.將int轉換爲char?
是什麼'裁判void'嗎? – sigod
@Kerbiter你爲什麼在那裏使用ref?在任何一方面? 'ref int'當它只被讀取時是一個完全的浪費,'ref char [] []'同樣只是在這裏增加了另一個間接的方法。 –