[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dlsym() and C++
Magnus Norddahl wrote:
> Quoting Pierre Phaneuf (pp@ludusdesign.com):
>
> > One trick that I use is this. In the header file:
> > /* everything short of the constructor must be pure virtual */
> This is exactly what ClanLib does. It's great that we agree on that one.
Yep, me too : I had never used a DLL before, let alone try
loading a C++ class, but when messing with it I 'invented'
exactly the same solution : use a function to build them for
you. The amazing thing is that it actually works; since the 'new'
is in the lib, it'll "new" and construct the class in DLL space,
which may not be the client program's space (right ?..),
yet things work fine when the client goes calling virtual
functions, which require a lookup in the vtable. Strong stuff :)
Anyway, Pierre has a point that the strong link C++ enforces
between interface and implementation is a problem. From
what I've read about OLE, the COM model is a pretty
neat way around this. It works by putting the functions
you can call in a separate object. The actual object
containing the data then has only 1 member, which
returns a pointer to that interface sub-object. Obviously,
this one-and-only member can be made so that it returns
a different pointer/interface according to a parameter,
which gives you inheritance and polymorphism all
in one shot. It sounds neat (especially for M$ I guess
they ripped it somewhere :) though I'm not sure this
short explanation is sortof clear ;)
Bert
--
-=<Short Controlled Bursts>=-