C ++创建和显示智能指针数组的值

时间:2017-11-14 15:21:42

标签: arrays c++11 smart-pointers

为什么我无法从此代码中看到smartPtr2D的输出值?

shared_ptr<shared_ptr<int[3]>[5]> smartPtr2D;
for (int i = 0; i<3; i++)
{
    for (int j = 0; j<5; j++)
    {
        smartPtr2D[i][j] = 11;
    }
}

for (int i = 0; i<3; i++)
{
    for (int j = 0; j<5; j++)
    {
        cout << "value:" << smartPtr2D[i][j] << endl;
    }
}

0 个答案:

没有答案