[Qt-interest] Can you spot my mistake.

Andrew Hodgkinson ahodgkinson at endurancetech.co.uk
Mon Aug 24 16:47:16 CEST 2009


On 24/08/2009 15:33, John McClurkin wrote:

> Well, it's not problematic for those who expect and exploit that
> behavior.

The use of a reference type seems to be an issue, because we have a 
thread in which several contributors describe their encounter with the 
same problem as the OP. I suppose this is a wider C++ consideration; 
imagine that we used this QApplication constructor instead:

   QApplication(int * argc, char ** argv) {}

Now we try to implement MyApp as before:

   MyApp(int argc, char ** argv) : QApplication(argc, argv) {}

Before, the code would compile with no warnings, link, run and eventually
crash. Now it won't even compile and the compiler's error would make the
mistake very obvious.

Does anyone know why a reference rather than a pointer is seen as a
better choice in this particular case?

-- 
TTFN, Andrew Hodgkinson
Find some electronic music at:     Photos, wallpaper, software and more:
http://pond.org.uk/music.html                        http://pond.org.uk/



More information about the Qt-interest-old mailing list