static的一个心得,自己学习用
2007-03-01 13:10
330 查看
//仅仅供自己学习记录一下的.
#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;
}
#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;
}
相关文章推荐
- 注意this用法,以及当用static 修饰属性时,无论生成多少个对象,其共同拥有一个属性,不再各自拥有自己的属性
- 《C语言入门1.2.3—一个老鸟的C语言学习心得》—清华大学出版社炮制的又一本劣书及伪书
- Java入门1.2.3—一个老鸟的Java学习心得
- JPA学习总结(搜罗的其他前辈们的知识结晶加上自己的一点点心得)(1)
- 小弟自己弄的一个asp.net的学习网站
- 深度学习一:自己写java代码,训练一个神经元
- onvif学习笔记8:最近写的一个ONVIF客户端的心得小结
- win32sdk学习-简单的创建一个自己的工具栏
- 学习的时候给自己一个目标
- 一个清华学子写的关于directshow的学习心得。8错。
- 学习地方做一个自己拯救自己心灵的人
- java学习心得(给类一个空参的构造器)
- [号召] 大家去写自己学习SICP的心得呀!!
- C++易混知识点4: 自己编写一个智能指针(Reference Counting)学习auto_ptr和reference counting
- shell学习心得 一个有趣的小技巧
- 自己学习心得:HQL数据查询基础
- 记录自己学习心得以及工作中遇到问题的总结
- 学习笔记之 WCF (Svcutil.exe) 在自己的博客中有一个写证的
- 自己学习JSP写的一个小程序
- TOMCAT内核之旅--一个简单的Servlet容器--学习心得(二)