Muistiinpano
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää kirjautua sisään tai vaihtaa hakemistoa.
Tämän sivun käyttö edellyttää valtuutusta. Voit yrittää vaihtaa hakemistoa.
'
new': cannot allocate 'void' objects
Remarks
The new operator allocates memory and constructs an object of the specified type. Since void isn't a constructible type, use ::operator new(size) to allocate raw memory without object construction.
Example: Wrong allocation type
// compile with /c
int main()
{
void* ptr1 = new void; // C2469
int* ptr2 = new int; // OK
}
Example: Allocate untyped memory
To allocate untyped memory, use ::operator new:
// compile with /c
int main()
{
void* ptr1 = new void; // C2469
void* ptr2 = ::operator new(4); // OK
}