我有一个指针分配给指针的双数组.
// pointer to pointer
int **x = new int *[5]; // allocation
for (i=0; i<5; i++){
x[i] = new int[2];
}
for (i=0; i<5; i++){ // assignment
for (j=0; j<2; j++){
x[i][j] = i+j;
}
}
for (i=0; i<5; i++) // deallocation
delete x[i];
delete x;
Run Code Online (Sandbox Code Playgroud)
我试图这样做unique_ptr:
std::unique_ptr<std::unique_ptr<int>[]> a(new std::unique_ptr<int>[5]);
for (i=0; i<5; i++)
a[i] = new int[2];
Run Code Online (Sandbox Code Playgroud)
但一直都是这样说的错误no operator = matches these operands.我在这做错了什么?