I have an overload delete operator as below
//////////////////////////////////
void operator delete(void* mem,int head_type) {
mmHead local_Head = CPRMemory::GetM emoryHead(head_ type);
mmFree(&local_H ead,(char *)mem);
CPRMemory::SetM emoryHeadAs(loc al_Head,head_ty pe);
}
/////////////////////
void* operator new(size_t sz, int head_Type) {
char *mem;
mmHead local_Head = CPRMemory::GetM emoryHead(head_ Type);
mem = mmAlloc(&local_ Head,sz);
CPRMemory::SetM emoryHeadAs(loc al_Head,head_Ty pe);
if(!mem) cout<<"Out of Memory"<<endl;
return mem;
}
////////////////
and using it as
SmC* s1 = new(WORK_HEAD) SmC;
operator delete (s1,WORK_HEAD) ;
But the problem is overloaded delete operator is not calling the
destructor of class SmC.
Do I have to call the destructor explicitly?
Any suggestions please.
//////////////////////////////////
void operator delete(void* mem,int head_type) {
mmHead local_Head = CPRMemory::GetM emoryHead(head_ type);
mmFree(&local_H ead,(char *)mem);
CPRMemory::SetM emoryHeadAs(loc al_Head,head_ty pe);
}
/////////////////////
void* operator new(size_t sz, int head_Type) {
char *mem;
mmHead local_Head = CPRMemory::GetM emoryHead(head_ Type);
mem = mmAlloc(&local_ Head,sz);
CPRMemory::SetM emoryHeadAs(loc al_Head,head_Ty pe);
if(!mem) cout<<"Out of Memory"<<endl;
return mem;
}
////////////////
and using it as
SmC* s1 = new(WORK_HEAD) SmC;
operator delete (s1,WORK_HEAD) ;
But the problem is overloaded delete operator is not calling the
destructor of class SmC.
Do I have to call the destructor explicitly?
Any suggestions please.
Comment