In general, you cannot assume that, since the order of creating a static object in different translation units is not specified. In this case, it will work, because there is only one translation unit:
#include <iostream>
Output:
Singleton contains: 100
But what if A::staticA in a definition in a different translation unit? Will it be created before static Singleton ? You cannot be sure.
xinaiz
source share