[Qt-interest] Why is assignment of overloaded classes not possible with QScopedPointer?

Matthias Pospiech matthias.pospiech at gmx.de
Sun Apr 25 00:10:27 CEST 2010


This code does not compile
    QScopedPointer<QPlotFunction> function;
    switch (functionID)
    {
    case PlotFunction::Gauss:
        function = new GaussianFunction;

with error:
error: no match for 'operator=' in 'function = (operator new(32u), 
(<statement>, ((GaussianFunction*)<anonymous>)))'
note: candidates are: QScopedPointer<T, Cleanup>& QScopedPointer<T, 
Cleanup>::operator=(const QScopedPointer<T, Cleanup>&) [with T = 
QPlotFunction, Cleanup = QScopedPointerDeleter<QPlotFunction>]

whereas a normal pointer works:
    QPlotFunction * function;
    switch (functionID)
    {
    case PlotFunction::Gauss:
        function = new GaussianFunction;

anyone knows why ?

Matthias



More information about the Qt-interest-old mailing list