[Interest] QScopedPointer with

Alex Strickland sscc at mweb.co.za
Tue Sep 18 16:58:00 CEST 2012


Hi

This is really a general C++ question, but I have looked long and hard 
and not worked it out. In the code below how should I initialise v.v 
using the QScopedPointer?

#include <QScopedPointer>

class abc
{
};

class a : public abc
{
};

class x
{
public:
     QScopedPointer<abc> v;
};

int main()
{
     x y;
     y.v = new a;    // error: C2679: binary '=' : no operator found 
which takes a right-hand operand of type 'a *' (or there is no 
acceptable conversion)
     y.v = dynamic_cast<QScopedPointer<abc>>(new a); // error: C2680: 
'QScopedPointer<T>' : invalid target type for dynamic_cast
}

Thanks for any help.
-- 
Regards
Alex



More information about the Interest mailing list