Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!nstn.ns.ca!clyde.concordia.ca!antares.concordia.ca!marcap From: marcap@antares.concordia.ca ( MARC ANDREW PAWLOWSKY ) Newsgroups: comp.lang.c++ Subject: Want pointers on intelligent pointers Summary: How do I do it? Message-ID: <838@antares.Concordia.CA> Date: 15 Mar 91 03:36:59 GMT Sender: news@Antares.Concordia.CA Organization: Concordia University, Montreal Quebec Lines: 43 Nntp-Posting-Host: antares.concordia.ca I am trying to make a smart class so objects will not delete themselves if someone is pointing to them. I have been following the discussion so far and came up with the following: Each object keeps a counter which indicates how many objects are pointing to it. To keep the counter valid it is necessary for the class to have its own copy, and reference routines. when the object is to de deleted, the counter is decremented. If the counter is less than or equak to zero then all the objects which are pointed to by the object to are deleted, then the object is deleted I have successively done this in C, but am having trouble doing this in C++. The trouble is that I would like for my deletion routine to be the destructor. But if my interpetation of ARM is correct then the destuctor will destroy the object no matter what I do. Is there a way to have the destructor return without the object being destroyed. Next beginners question: In my creation routines can I refer the the object being created? I have a class Box which has a global variable called "default_box". I also have a function "operator =" that will copy a box into this. can I do something like Box::Box(void) { this = default_box; // does not work with TC++ 1.01 return this; // return not allowed } could not find an answer one way or the other in ARM or the TC++ manuals. Thanks in advance Marc Pawlowsky