help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic module loading vs. using ancestor class functions


From: Ulrich Eckhardt
Subject: Re: dynamic module loading vs. using ancestor class functions
Date: Sat, 22 Jan 2005 12:59:38 +0100
User-agent: KNode/0.8.1

FEJES Jozsef wrote:
> There's a problem I can't solve about dynamic module loading with C++. 
> Let's see a simple example. It'll be just a theoretical illustration. I 
> have a simple socket interface (abstract class) with a constructor, 
> init(), connect() and read(). There's a simple socketv4 class in the 
> socketv4.so module that implements all functions. Now I want a socketv6 
> class in socketv6.so module, whose ancestor is socketv4. (I know it 
> could be compiled together with socketv4, but it's just illustration. 
> There are two different modules.) 

The thing you talk about is a non-issue. The point is that every
module/library/program that uses part of another library needs to be
linked with that library. So, in order to build socketv6, you need to link
to the library that implements the base. Both (and other dependencies) are
automatically loaded by dlopen().

One note: your design smells. A socket of an IPv6 connection is not an IPV4
socket. They are both sockets, but that's it. Therefore: make a baseclass
that handles the common parts (some people would advocate to even make
this a pure interface-class without any code associated) and derive both
socket-types from it.

Another note: little of this has anything to do with GCC's C++ compiler.

Uli

-- 
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]