Re: Inheritance basic issue form newbie
From: Leor Zolman (leor_at_bdsoft.com)
Date: Sun, 04 Apr 2004 03:12:54 GMT
On Sat, 3 Apr 2004 20:30:01 +0200, "Marco" <m.traversoNOSPAM@libero.it>
>Well, I didn't explain the situation: it's a plug-in that is hosted in an
>external App. It is compiled into different modules that are "commands"
>called from within the host app. Every command creates a derivedX object
>with a "derivedX objx;" instruction and destroys all its local variables at
>the end of its execution. The fact is that I need to store the created
>objects so that when another command is executed it can access the
>previously created objects...
>I hope I clarified my "situation"...
Since I don't deal with plug-ins and such myself, I have a difficult time
relating to your particular environment, but fortunately there are lots of
other folks who read this group and are likely to have a good handle on it.
>> >so once I create a derived1 obj1 object
>> >I need to store them in a "global container" to make them available even
>> >after the call to the destructor function (that destroys the obj1
>> Whoa. Not sure what you're trying to say there, but no object remains
>> "available" after its destructor has run; that's why it is called a
>Actually I can store an object as a global variable, or better, a member of
>a global class (declared in another "module") that is accessible from all
What about having the global container (array or whatever) just store
pointers to the base class. In whatever function obj1 is first
instantiated, create a dynamically-allocated copy of obj1 and install a
pointer to in the container. Then when the original obj1 turns into a
pumpkin, you've got the copy on the free store (complete with all of its
properties) and a pointer to it.
-- Leor Zolman --- BD Software --- www.bdsoft.com On-Site Training in C/C++, Java, Perl and Unix C++ users: Download BD Software's free STL Error Message Decryptor at: www.bdsoft.com/tools/stlfilt.html