When memory will be created for myClass object pointed by ptr ??
During the dynamic initialisation stage, before main
begins. Beware the initialisation order fiasco: it might not be created before other static variables in other translation units, so you might have big problems if their initialisers try to access it.
is below single tone thread safe ??
If you don't start any threads before main
begins, then yes. If another static variable's initialiser starts a thread, then maybe not.
I would recommend you avoid global variables altogether, whether or not you try to disguise them as singletons. It's difficult implement that anti-pattern safely and correctly in C++. (I would say impossible, since I don't know of any way to do it, but according to the comments someone knows better than me.)