一些代码

来源:互联网 发布:西游记后传知乎 编辑:程序博客网 时间:2024/06/05 14:54
Singleton的实现:
  1. class Singleton  
  2. {  
  3. public:  
  4.     static Singleton* getInstance();  
  5. protected:  
  6.     Singleton(){};  
  7.     ~Singleton(){};  
  8. private:  
  9.     static Singleton* Instance;  
  10. };  
  11.   
  12. Singleton* Singleton::Instance = 0;  
  13.   
  14. Singleton* Singleton::getInstance()  
  15. {  
  16.     if(Instance == 0) //position 1  
  17.         Instance = new Singleton();  
  18.     return Instance;  

-----------------------------------------------------------

树的前中后递归遍历

void PreTraverse(BinNode* root, void (*fn)(const BinNode*))

etc.

-----------------------------------------------------------



原创粉丝点击