有这样的准则:
#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;
}
结果:
wsk2: 0x928e008 5
wsk2: 0x928e008 0
我读到过 new
不用0初始化内存。但在这里似乎是这样的。它是怎么工作的?