new1.c
来自「this is a gcc file, you can download it 」· C语言 代码 · 共 34 行
C
34 行
// Test whether N::operator new is different from ::operator new#include <new>#include <cstdlib>bool success;namespace N{ void* operator new(size_t n){ success = true; return std::malloc(n); }}void *operator new(size_t n)throw(std::bad_alloc){ static bool entered = false; if(entered) throw std::bad_alloc(); entered = true; void *result = N::operator new(n); entered = false; return result;}int main(){ try{ new int; }catch(...){ return 1; } return success?0:1;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?