Tip: 如何保證一個類只能在堆上被建立

有的時候爲了保證一個類的對象必須在堆上被建立, 好比當咱們須要手動控制一個對象的生命週期的時候, 這個時候就必須保證這個對象是在堆上建立的, 如何保證呢, 有個小的技巧:函數   class A this {對象 public:生命週期     void Close() {delete this; }class private:object     ~A() { ... };技巧 };error
相關文章
相關標籤/搜索