static的一個心得,自己學習用

//僅僅供自己學習記錄一下的.

#include <stdio.h>

class ca
{
public:
 void print_static(long c)
 {
  static long countor = 0;
  printf("=== %d.countor %d ===/n",c,++countor);
 }
};

int _tmain(int argc, _TCHAR* argv[])
{
 static long countor = 0;

 ca * p = new ca;

 if(p)
 {
  p->print_static(++countor);
  p->print_static(++countor);

  delete p;
 }

 p = new ca;
 if(p)
 {
  p->print_static(++countor);
  p->print_static(++countor);

  delete p;
 }

 system("PAUSE");

 return 0;
}
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章