I have a pointer to a QScriptEngine
that I'm passing through the overloaded class constructor of class Evaluator
and assigns it to QScriptEngine *engine_
(class Property
subclasses Evaluator
, and calls this constructor of Evaluator
, passing it an already allocated QScriptEngine
). The constructor with no arguments creates the new QScriptEngine
pointer (class Generic
subclasses Evaluator
in this way). In the destructor I test if engine_
is not NULL
, delete the pointer, then assign it NULL
. Should the pointer (engine_
) in the derived Property
now also be NULL
? Something tells me this is not the case. If not, how do you deal with this situation? I need the QScriptEngine
to be the same instance throughout. QScriptEngine
's = operator is private, or I would be avoiding the pointer all together.
I saw some info on shared pointers (boost::shared_ptr
and std:tr1::shared_ptr
) in another SO question. I'm already using boost for the regex library, so boost is not out of the question if that's the best way to deal with this. Hopefully there's a non-boost way, for general C++ knowledge and future projects.