object - Why prohibit static allocation in c++? -


what point making constructor of class private , having getinstance method returns new instance? when want allow dynamic object creation , why? have seen examples of , don't understand why.

this commonly done when class instances manage own lifetime, e.g. subscribe event comes asynchronously. if instance destroyed before event arrives, event dispatcher use wild pointer , cause undefined behavior.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -