[C++] 分别设计只能在栈, 堆中分配内存的类!
#include <iostream> using namespace std; class HeapOnly { public : HeapOnly() {} void destroy() const { delete this; } private : ~HeapOnly() {} }; class HeapStack { private : static void* operator new(size_t size); }; int main() { return 0; }