12345678910111213141516171819202122
#include<iostream> using namespace std; typedef unsigned int P; struct A{ static allocator<A>m; P p; void*operator new[](size_t s){return m.allocate(s);} void operator delete[](void*p,int s){m.deallocate((A*)p,s);} }; int main(){ A*a=new A[10]; //delete (5) []a; //delete[5]a; //delete[] (5) a; //delete[]a (5); //delete[]((int)5)a; //delete[]a((int)5); return 0; }
12345678910111213141516
#include<iostream> using namespace std; typedef unsigned int P; struct A{ static allocator<A>m; P p; void*operator new[](size_t s){return m.allocate(s); } void operator delete[](void*p, size_t s){m.deallocate((A*) p, s); } }; int main(){ A*a = new A[10]; delete[] a; }