At 10:19 PM 2/17/00 -0800, you wrote:
>1) Why is this generating global data?  It seems the virstual function
>table would have to be stored with the instance of the object, since the
>type of object won't be known until run time.

The virtual function table is not stored with the instance, it is the same
for all instances of the same class.  For example, if I have:

class A
{
  virtual void DoSomething ();
};

class B : public A
{
   virtual void DoSomething();
};

I would have two virtual tables - one for class A, one for class B.  Each
instance of class A or class B would have a pointer to this virtual table.
These virtual tables are stored in global memory.  Because of this, they
can't really be used in shared libraries (at least not without way more
work than I'd be willing to put in).

>2) Is there anyway around this, other than abandoning virtual
>functions.  This is not too bad in my case, but it would obscure a
>rather easy to understand piece of code.

Unfortunately there is no easy way to do this in a shared library.  One
thing I've done with relative success is to have a function pointer as a
member of the object, and load that as part of the constructor.  This
should be safe in shared libraries.

Hope this helps.

Greg
Greg Winton
Bachmann Software and Services, LLC
http://www.bachmannsoftware.com
Home of Bachmann Print Manager, the only graphical printing solution for
the PalmOS

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to