I saw this question on SO and wondered where this kind of code can actually be used in the real time example.
struct a
{
static struct a b;
};
int main()
{
a::b;
return 0;
}
Also what is the significance of a::b;
Thanks for your inputs.
Such code can be used in implementation of the Singleton pattern. Here, one instance of type
ais declared; if other instances are somehow forbidden, it is the singleton. In practice, however, i recall, they usually use less confusing syntax.And, as for
a::b, it does nothing useful. It just shows the name of the instance. A more useful example would be this: