Now I know that, as a rule, itβs bad to add new virtual functions to non-classical classes, since it violates binary compatibility for any derived classes that have not been recompiled. However, I have a slightly different situation:
I have an interface class and an implementation class compiled into a shared library, for example:
class Interface { public: static Interface* giveMeImplPtr(); ... virtual void Foo( uint16_t arg ) = 0; ... } class Impl { public: ... void Foo( uint16_t arg ); .... }
My main application uses this shared library and can basically be written as:
Interface* foo = Implementation::giveMeImplPtr(); foo->Foo( 0xff );
In other words, the application does not have classes that are derived from Interface , it just uses it.
Now let's say I want to overload Foo( uint16_t arg ) with Foo( uint32_t arg ) , I'm safe:
class Interface { public: static Interface* giveMeImplPtr(); ... virtual void Foo( uint16_t arg ) = 0; virtual void Foo( uint32_t arg ) = 0; ... }
and recompile my shared library without recompiling the application?
If so, are there any unusual reservations that I need to know about? If not, do I have any other options besides taking a hit and updated version of the library, thereby violating backward compatibility?
source share