Section 3.6.3.2 of the C ++ 03 standard states:
Destructors for initialized objects of static storage duration (declared at block scope or at namespace scope) are called as a result of returning from main and as a result of calling exit.
It does not give any restrictions regarding the presence of a private destructor, so basically, if it is created, it will also be destroyed.
A private destructor causes a restriction on the ability to declare an object (C ++ 03 12.4.10)
A program is ill-formed if an object of class type or array thereof is declared and the destructor for the class is not accessible at the point of declaration
but since the destructor A :: theMainInstance is available at the declaration point, your example should not have an error.
source share