I have a class with a static member that has a pointer like this:
animation.h
class Animation { public: Animation(); static QString *m; };
animation.cpp
#include "animation.h" QString* Animation::m = 0; Animation::Animation() { }
When I try to initialize this pointer 'm' from another class, for example:
Animation::m = new QString("testing");
He works.
But when I do it like this:
QString x("Testing"); Animation::m = &x;
Program crash.
What is wrong with this second method?
I would also like to have this static pointer as private, so I can make the getter and setter static functions for it. The installer should use the second method, since "x" will appear in the parameter, so I'm stuck.
Thanks for any help!
Yassir ennazk
source share