我知道如何通過分配器創建1d數組(如a[10]
)。舉例來說,這裏是從cppreference抽象:如何爲int a [10] [10]分配內存分配器
#include <memory>
#include <iostream>
#include <string>
int main()
{
std::allocator<int> a1; // default allocator for ints
int* a = a1.allocate(10); // space for 10 ints
a[9] = 7;
std::cout << a[9] << '\n';
// the remainder was omitted .....
return 0;
}
我不知道,但知道如何創建一個二維數組,像int a[10][10]
。有人可以幫我解決這個問題嗎?
這不是'C' .. –
[我如何在C++中使用new聲明一個2d數組](http://stackoverflow.com/questions/936687/how-do-i-declare-a-2d- array-in-c-using-new) – Rogus