class Array2
{
int row, col;
int (*p)[];
public:
Array2(int row_ = 0, int col_ = 0) : row(row_), col(col_)
{
p = new int[row][col];
}
};
vscode在new那行的col处波浪线提示“this”不能在常量表达式中使用,试图编译则会报错:error: only the first dimension of an allocated array may have dynamic size
p = new int[row][col];
^~~
note: implicit use of 'this' pointer is only allowed within the evaluation of a call to a 'constexpr' member function
我该怎么写以实现根据构造函数参数new处连续空间?