ポインターからポインターへのポインターによって割り当てられた double 配列があります。
// 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;
私はこれを使用してこれをやろうとしています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];
しかし、それを言ってエラーが発生し続けましたno operator = matches these operands
。ここで何が間違っていますか?