[Interest] QDirIterator as Variable in class
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Tue Apr 23 16:23:16 CEST 2013
Il 23/04/2013 14:12, Adrian Stern ha scritto:
>
> MediaBase::MediaBase(QObject *parent) : QObject(parent) {
Error 1, straight from the compiler: since you're not calling a
QDirIterator constructor in your constructor's initializer list for the
mediaItr data member variable, the compiler calls the default
constructor. But QDirIterator lacks a default constructor. Therefore,
you got an error
> QDirIterator mediaItr();
Error 2, much more subtle: this is declaring a function called mediaItr,
taking no arguments, returning a QDirIterator, and shadowing the member
variable of the same name. (Yes, it's the C++ most vexing parse.) I know
why you did this, but this is nonsense. Just remove it.
Note: I'm deliberately NOT writing the "solution" because I'd like to
encourage you to search the web for all the keywords I used
("initializer list", "member", "default constructor", "most vexing
parse"). This is a C++ problem, not a Qt one.
HTH,
--
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
More information about the Interest
mailing list