Daily Archives: July 27, 2017

protected destructor

constructor access modifier 一般設為public,而在singleton中,為了限制生成的物件個數,會將constructor放在private,另外在其他method生成物件。而對於destructor,以Meyers Singleton的實作來說,destructor放在public or non-public皆可,因為static object 在宣告的地方可以存取到private destructor(參考下面12.4) C++03 std §3.6.3 Termination Destructors (12.4) for initialized objects of static storage duration (declared at block scope or at namespace scope) are called as a result of returning from main … Continue reading

Posted in C++ Language | Leave a comment