为什么代码错了?
程序代码:
#include <cstddef> #include <iostream> #include <conio.h> using namespace std; class Cat { public: Cat(){cout<<"cat()"<<endl;} ~Cat(){cout<<"~Cat()"<<endl;} }; class Dog { public: void *operator new(size_t sz){ cout<<"allocating a Dog"<<ebdk; throw 47;} void *operator delete(void *p){ cout<<"deallocating a DOG"<<endl; delete p;} }; class Use { private: Cat *bp; Dog *op; public: Use(int count=1){ cout<<"USE"<<endl; bp=new Cat[count]; op=new Dog;} ~Use(){cout<<"~use"<<endl; delete []bp; delete op;} }; int main() { try{ Use ur(3); }catch(int){ cout<<"error!"<<endl;} getch(); return 0; }///:~这段代码是演示代码,哪里错了?为什么计算机上错误一大堆?
[ 本帖最后由 lyj23 于 2011-5-18 20:40 编辑 ]