Tuesday, November 27, 2007

Re: C++ Globals Registry Problem

On Nov 27, 2007 9:32 PM, BlueRaja <blueraja.admin@gmail.com> wrote:
> > 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.'

Ah, yes, I had forgotten that static objects don't really exist. They
can have static members, but they're not really static, so having a
constructor/destructor is rather inappropriate.

I learned that all in Java, it's coming back to me now... slowly :)

--
Registered Linux Addict #431495
http://profile.xfire.com/mrstalinman
John 3:16!

--~--~---------~--~----~------------~-------~--~----~
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