> -----Original Message-----
> From: [email protected] [mailto:interest-
> [email protected]] On Behalf Of Guido Seifert
> Sent: Friday, April 04, 2014 3:58 PM
> Cc: [email protected]
> Subject: Re: [Interest] QFileInfoList inheritance producing warnings
> 
> 
> > Well, you _can_, as long as you only add methods and no members. Qt
> does it too, with QQueue and QStack for instance.
> > It can be convenient to add some nice API.
> 
> You can, but you should not. Convenient can also be interpreted as lazy. ;-) I
> would use a composition approach. Deemed to be more flexible. Why
> inheritance was used in QQueue and QStack? Simpler code? Better
> readability?

I can completely see where you are coming from here Guido, but there is also a 
very good reason
to use inheritance other than being "lazy." I mean we are all coders right? 
Were we not taught that
software reuse is a must and NEVER to reinvent the wheel? Yes, composition will 
give me the same
functionality, but it will NOT give me the methods that are provided with the 
class I inherit. Therefore,
if I want to replicate those methods, is it really better to rewrite them all 
and just call the same method
in the object that is now composed instead of inherited? Yes, I can inline 
these calls and the compiler 
should be smart enough to inline the calls for performance, but why should I 
have to rewrite 50 different
methods just to call the same exact methods in the class?

I would guess that the reason the class was not written with any virtual 
methods was for performance (and, 
yes I know that this is a pretty large increase in performance), but I don't 
need a virtual destructor, nor do I need
any virtual methods, I just want to add some extra methods to this particular 
array to make coding easier on our
developers. The Qt developers have done it; therefore, they obviously see the 
benefit... just trying to figure
out why I can't do it...

I have worked around the warnings by using a QVector instead, but it would 
still be nice to know why QList
is producing all of these warnings...

I really appreciate your feedback by the way!
Eric

> Performance reasons? No idea. If someone can give a reason, it is probably
> Thiago. :-D
> 
> Guido
> _______________________________________________
> Interest mailing list
> [email protected]
> http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to