我需要给类内的矩阵一个大小,但是const int size
编译器会抱怨。有一种优雅的方式可以满足我的需求吗?
头文件.h
class ChessBoard {
int matrix[<size>][<size>];
public:
ChessBoard(int s): <size>(s) {}
};
主文件
#include "header.h"
#include <iostream>
int main() {
std::cout << "Enter the size of the chessboard: ";
int n;
std::cin >> n;
ChessBoard cb(n);
return 0;
}