Re: Shared Library and C++ Classes
Keith Halligan wrote:
Rainer Lehrig wrote:
An advantage of a shared library is,
that you don't need to relink your apps
if you do not change the interface of the library.
Question:
If you add a new method to a class,
will you have to relink the apps, that use the lib ?
As others have said once it's a non-virtual member then you should be
ok.
Some other things that will break binary compatibility of a shared lib
on most compilers are:
-> Reordering virtual members
-> Making a function virtual
-> Reordering base classes
-> Adding or removing a base class
-> Adding or removing a data members (if this class is exported)
Adding or removing private static data members should be OK. Here's
a trick some may find useful. When adding a regular data member is
not possible, you can add a private class-wide storage of type
'std::map<yourclass*, wanteddatatype>', for example, and store the
emulated non-static "members" by keying them off 'this' pointers.
Ugly, but sometimes you have to do it.
-> Reordering data members.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask