C ++中的动态二维数组 [英] Dynamic 2d array in C++

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

问题描述

我想创建一个动态的二维数组,但最终出现以下错误:



I wanted to create a dynamic 2d array , but ended up with the following error :

[Error] C:\Users\User\Documents\C-Free\Temp\Untitled2.cpp:8: E2034 Cannot convert ''int ( *)[100]'' to ''int *'' in function main()





这是使用Borland C ++ 5.5编译的。



下面是麻烦的代码:



This was compiled using Borland C++ 5.5.

Below is the troublesome code :

int * h = NULL;
    h = new int[100][100];
    if(h==NULL)
    {

        cout<<"\nERROR : No more space available.";
        exit(1);

    }





这有什么问题?如果错误,正确的语法是什么?

还建议如何释放它使用的内存。

推荐答案

参见 C ++中动态二维数组的介绍 [ ^ ]。


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

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