TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PAUL WANKADIA
from: KEVIN CAMPBELL
date: 1997-04-22 17:36:00
subject: self-destruct

 > On 11 Apr 97, Kevin Campbell wrote to Paul Wankadia --
 >> I'm wondering how to, from an object's constructor, to self-destruct.
 >> E.g. if there is some kind of error, the object will NOT be created.
 >  KC> Overload the new operator.
 > Oh crikey ...
 >  KC> If the object is created, return a pointer to it, else return NULL.
 > ... but a good idea, IMO.  Just tell me how to DO that ...
Simple. It's just the same as a standard class function entry or operator
overload. Define the function "void *operater new(size_t size)". Now make the
code for it as void *xxxx::operator new(size_t size){
}
Where xxxx is the function name.
In the function, you simply allocate the memory, and return a pointer, 
alling
a terminate function if you like if you can't get the memory.
- Kev
--- FMail/386 1.02
---------------
* Origin: Mail shipped from Deimos Spaceport (2:259/17)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.