In these days I’m porting a library from Qt4 to Qt5, and here’s how sticking to C++11 syntax has helped me catching a subtle porting problem. I had a class subclassing QTcpServer, overriding a virtual method with this syntax:

void incomingConnection(int descriptor) override;

Specifying the method as override  was enough to discover a breaking change in Qt API, which would have otherwise silently changed the meaning of my code.

In Qt5, in fact, they changed the signature of the original virtual method to incomingConnection(qintptr), and this alone was enough to transform my overriding method into an overloading method, completely changing the meaning and the behavior of my class.

This shows how adding a little and apparently useless keyword has helps preventing problems in the future!

1 Comment

  1. Vineel Kumar Reddy

    Thanks for the post.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.