[Qt-interest] Library binary compatibility issue

Giacomo S. giacomo.strangolino at elettra.trieste.it
Tue May 25 12:00:44 CEST 2010


Il giorno ven, 21/05/2010 alle 18.43 +0200, Thiago Macieira ha scritto:
> Em Sexta-feira 21 Maio 2010, às 14:27:20, Giacomo S. escreveu:
> >  I thought that reimplementing a virtual method declaring its
> > implementation as non virtual would have removed the virtual
> > behaviour...
> 
> Once virtual, it's virtual forever. So the "virtual" keyword is optional in 
> overriding. 
> 
> But if you get the method signature wrong, instead of overriding, it simply 
> shadows the original virtual method. This is something that C# got right and 
> the original C++ didn't, but C++0x allows for fixing.
> 
> That is, when you write a virtual function, you declare whether it's a new 
> virtual, or whether you're overriding a virtual. Then the compiler can tell 
> you when you think you're declaring a new one but you're actually overriding, 
> or when you think you're overriding but you're not.
> 


That's all good, thanks. But what about binary compatibility in this
case:

class Reader
{
  ...
  protected:
	void configure(const TVariant&); /* standard configure() implementation */
}

class Label : public QLabel, public Reader
{
	...
	protected:
		void configure(const TVariant&) ; /* reimplement configure */
}

if I make configure() virtual in class Reader:

class Reader
{
  ...
  protected:
	virtual void configure(const TVariant&); /* in version 2 I want it virtual */
}

and in Label

class Label : public QLabel, public Reader
{
	...
	protected:
		virtual void configure(const TVariant&) ; /* implement refresh */
}

is the library binary compatible with applications using Label??

Thanks again.

Giacomo.


> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest






More information about the Qt-interest-old mailing list