笔记,c++中静态对象在程序结束的时候会不会进析构函数?

转载链接    https://blog.csdn.net/life_is_too_hard/article/details/52207104

1.直接在静态存储区上放的对象会进入析构函数。

  1. void func()  
  2. {  
  3.   static classA a;  
  4. }  

2.在静态存储区放对象指针,而对象本身在堆上,这种形式不会进入析构函数。

  1. void func()  
  2. {  
  3.    static classA* pA = new classA;  

猜你喜欢

转载自blog.csdn.net/qq_34358193/article/details/80661024
今日推荐