如何在C ++中动态创建新的2D数组 [英] How create dynamically new 2D array in C++

查看:132
本文介绍了如何在C ++中动态创建新的2D数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C ++中创建新的2D数组的主题?
下面的代码不能很好地工作。

As in the subject how create new 2D array in C++? This code below does not work quite well.

int** t = new *int[3];
for(int i = 0; i < 3; i++)
       t[i] = new int[5];


推荐答案

您有 / code>在错误的地方。尝试:

You have a * in the wrong spot. Try:

int **t = new int *[3];

这篇关于如何在C ++中动态创建新的2D数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆