Invent a type to allocate a static obejct?
In TC++PL, the author said,
Sometimes when you design a library, it is necessary, or simply
convenient, to invent a type with a constructor and a destructor with the
sole purpose of initialization and cleanup. Such a type would be used once
only: to allocate a static object so that the constructor and the
destructor are called.
This topic was already discussed in here. To sum up, It's about the
ambiguous allocational order before the main() starts. In other words, the
author presents his solution to make sure that, in the situation where one
object depend on another, the another is already allocated when the one
tries to access the another. Therefore, the solution the author proposed
attempt to secure the allocational order.
However, I really can't understand how it works. I mean, It seems the aims
as I mentioned above is irrelevant to the codes that the author gives us
as an example. Apparently, I must have missed some critical understanding.
Would you please explain it to me in a kindly manner? FYI, the codes that
I mentioned is in here.
No comments:
Post a Comment