Operator new inicializa la memoria a cero
Existe dicho código:
#include <iostream>
int main(){
unsigned int* wsk2 = new unsigned int(5);
std::cout << "wsk2: " << wsk2 << " " << *wsk2 << std::endl;
delete wsk2;
wsk2 = new unsigned int;
std::cout << "wsk2: " << wsk2 << " " << *wsk2 << std::endl;
return 0;
}
Resultado
wsk2: 0x928e008 5
wsk2: 0x928e008 0
He leído quenew
no inicializa la memoria con ceros. Pero aquí parece que sí. ¿Como funciona