1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> //~ #include <string> using namespace std; class demo { public: void* operator new(unsigned int size) //~ operator new must return "void *" { //~ do something like the following demo* ptr = ::new demo[size]; return ptr; } }; int main() { demo * ptr = new demo[9]; return 0; } |
你好!除了代码,此处没有多少原创之物,皆为本人搜集、整理、总结之记录与心得,欢迎转载分享!转载时请尽量注明出处,将不胜感激。祝你健康、快乐!
Be the first to comment on this entry.