TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: FRANK ADAM
from: JONATHAN DE BOYNE POLLARD
date: 1997-11-27 20:10:00
subject: awareness ?

 FA> Is it possible to make a class aware of another instance of itself ?
 FA> If it is, how would that be done ? 
Have a static data member that counts instances -- increment it in all 
constructors (remember to define your own copy constructor) and decrement it 
in the destructor.
Of course, this only works when your program doesn't involve threads or 
exceptions.  If you want thread safety and exception safety this scheme 
becomes much more complex to implement than two extra lines of code.  (-:
 ¯ JdeBP ®
--- FleetStreet 1.19 NR
---------------
* Origin: JdeBP's point, using Squish (2:440/4.3)

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™.