If you have a variable with a static duration, it is created when the application is initialized. When the application terminates, the object is destroyed. It is not possible to control the order in which various objects are created.
This change will make the object created when it is first used, and (since it is dynamically allocated) it will never be destroyed.
This may be good if other objects need these objects when they are destroyed.
Update
The source code accessed the object using the Data variable. The new code does not need to be changed in any way. When the code uses Data , it actually uses the Data macro, which will be expanded into getData() . This function will return a link to the actual (dynamically allocated object). In practice, the new code will work as a replacement for the old code, with the only noticeable difference being what I described in the original answer above.
source share