單例模式(懶漢式) 1. 將構(gòu)造方法私有化, 不允許外邊直接創(chuàng)建對象 2. 聲明類的唯一實(shí)例, 使用private static修飾 3. 提供一個(gè)用于獲取實(shí)例的方法, 使用public static修飾
2 回答
舉報(bào)
0/150
提交
取消
單例模式(懶漢式) 1. 將構(gòu)造方法私有化, 不允許外邊直接創(chuàng)建對象 2. 聲明類的唯一實(shí)例, 使用private static修飾 3. 提供一個(gè)用于獲取實(shí)例的方法, 使用public static修飾
2014-05-31
舉報(bào)
2014-08-01
This is one of the most simple way.We can also use enum class or inner calss to implement this pattern.
2014-06-01
enen