error C2440: 'initializing' : cannot convert from 'int (*)[4]' to 'int *' Types pointed to are un
#include<iostream>#include<string>usingnamespacestd;intmain(){int*pi=newint[2][4];//c...
#include <iostream>
#include<string>
using namespace std;
int main()
{
int* pi=new int[2][4];
//cout<<*pi<<" "<<pi<<endl;
delete pi;
return 0;
}
编译时出现如下错误请解释一下?
error C2440: 'initializing' : cannot convert from 'int (*)[4]' to 'int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 展开
#include<string>
using namespace std;
int main()
{
int* pi=new int[2][4];
//cout<<*pi<<" "<<pi<<endl;
delete pi;
return 0;
}
编译时出现如下错误请解释一下?
error C2440: 'initializing' : cannot convert from 'int (*)[4]' to 'int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 展开
2个回答
展开全部
int * pi = new int[2][4] 应该改成 int **pi = new int[2][4] 或者改成 int *pi = new[2]。主要看你想怎么用,
而且如果你知道你在做什么的话可以改成 int *pi = (int*) new int[2][4];
而且如果你知道你在做什么的话可以改成 int *pi = (int*) new int[2][4];
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询