小编Nib*_*jee的帖子

new(float*)[]和new float*[]之间的区别

有什么区别:new int*[]new (int*)[]:

int** pA = new int*[2] // returns a pointer to an array of pointers to int.

new (int*)[2] // what should this return ? Shouldn't it be same as the above. 
Run Code Online (Sandbox Code Playgroud)

同样,

float* pB1 = new float[3]; // compiles successfully.

float* pB2 = new (float)[3] //Gives an error. Shouln't it return an array of floats ?
Run Code Online (Sandbox Code Playgroud)

但是,编译器说:

A value of type 'float' cannot be used to initialize a value of type float* . …
Run Code Online (Sandbox Code Playgroud)

c++ arrays pointers

3
推荐指数
1
解决办法
2558
查看次数

标签 统计

arrays ×1

c++ ×1

pointers ×1