[Qt-interest] Why is assignment of overloaded classes not possible with QScopedPointer?
Thiago Macieira
thiago at kde.org
Sun Apr 25 13:23:58 CEST 2010
Em Domingo 25. Abril 2010, às 10.10.58, Matthias Pospiech escreveu:
> Thiago Macieira schrieb:
> > Em Domingo 25. Abril 2010, às 00.10.27, Matthias Pospiech escreveu:
> >> This code does not compile
> >>
> >> QScopedPointer<QPlotFunction> function;
> >> switch (functionID)
> >> {
> >>
> >> case PlotFunction::Gauss:
> >> function = new GaussianFunction;
> >
> > [snip]
> >
> >> anyone knows why ?
> >
> > Because there's no operator=()
> >
> > You have to write:
> > function.reset(new GaussianFunction);
>
> You are right, I completely forgot that this is a smart pointer...
Not any smart pointer, this is a non-ref-counted smart pointer that takes
ownership.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100425/3fc38f8a/attachment.bin
More information about the Qt-interest-old
mailing list