Tuesday, November 27, 2007

Re: C++ Globals Registry Problem

> And because the destructor is a function (technically) I could just
> throw a function pointer to the destructor, right?

No; the destructor is a method (member function), which means it needs a 'this' pointer in order to know what to deallocate.  Since your registry does not keep track of the object-instances themselves, you would have no way of specifying the object to destruct.

The suggestion given by the article you linked was to create a static method for each static ("global") variable; it is this method which will call the destructor of the object, and this method which you will pass as a reference to your 'registry.'

Hope that helps.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

<< Home