2017-10-11 3 views
3

Was ist der Unterschied zwischen: new int*[] und new (int*)[]:Unterschied zwischen neuen (float *) [] und neue Schwimmer * []

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. 

Ebenso

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

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

Aber der Compiler sagt:

A value of type 'float' cannot be used to initialize a value of type float* . 

Was fehlt mir hier? Ich verwende VS2015 Community IDE.

+0

wies Sie eine neue Platzierung anfordern; der Aufruf wird als Zeiger verstanden, der an new übergeben wird; siehe https://stackoverflow.com/questions/222557/what-uses-are-there-for-placement-new – OznOg

+0

http://en.cppreference.com/w/cpp/language/new – Barry

+1

@OznOg, sollten Sie Erweitern Sie den Kommentar zu einer vollständigen Antwort. –

Antwort

Verwandte Themen