Why the overrided operator new isn't call?
问题 I run the following code on VS2005: #include <iostream> #include <string> #include <new> #include <stdlib.h> int flag = 0; void* my_alloc(std::size_t size) { flag = 1; return malloc(size); } void* operator new(std::size_t size) { return my_alloc(size); } void operator delete(void* ptr) { free(ptr); } void* operator new[](std::size_t size) { return my_alloc(size); } void operator delete[](void* ptr) { free(ptr); } int main() { std::string str; std::getline(std::cin, str); std::cout << str;