#include <iostream.h>
#include <ctype.h>
class aClass{
int i;
float f;
static int total;
public:
static int getTotal(void);
aClass(int I,float F);
~aClass();
};int aClass::getTotal(void)
{
return aClass::total;
}
aClass::aClass(int I,float F)
{
i=I;
f=F;
aClass::total++;}
aClass::~aClass()
{
aClass::total--;
}
int aClass::total=0;
main()
{
aClass var1(1,2.2);
aClass var2(1,2.2);
aClass var3(1,2.2);
cout<<aClass::getTotal<<" object created so far\n";
cout<<"Create another in new\n";
{
aClass var4(1,2.2);
cout<<aClass::getTotal<<" object created so far\n";
}
cout<<"now there are only\n";
cout<<aClass::getTotal<<" object created so far\n";
return 0;
}
=============>上面是资料程序,期待输出是
3 object created so far
create another in new
4 orbject created so far
there are only
3 orbject created so far
==============>实际输出我怎么我觉得都变成地址了?
0x0040100F object created so far
Create another in new
0x0040100F object created so far
now there are only
0x0040100F object created so far
Press any key to continue
==========〉不明白中
#include <ctype.h>
class aClass{
int i;
float f;
static int total;
public:
static int getTotal(void);
aClass(int I,float F);
~aClass();
};int aClass::getTotal(void)
{
return aClass::total;
}
aClass::aClass(int I,float F)
{
i=I;
f=F;
aClass::total++;}
aClass::~aClass()
{
aClass::total--;
}
int aClass::total=0;
main()
{
aClass var1(1,2.2);
aClass var2(1,2.2);
aClass var3(1,2.2);
cout<<aClass::getTotal<<" object created so far\n";
cout<<"Create another in new\n";
{
aClass var4(1,2.2);
cout<<aClass::getTotal<<" object created so far\n";
}
cout<<"now there are only\n";
cout<<aClass::getTotal<<" object created so far\n";
return 0;
}
=============>上面是资料程序,期待输出是
3 object created so far
create another in new
4 orbject created so far
there are only
3 orbject created so far
==============>实际输出我怎么我觉得都变成地址了?
0x0040100F object created so far
Create another in new
0x0040100F object created so far
now there are only
0x0040100F object created so far
Press any key to continue
==========〉不明白中
解决方案 »
- 求救 关于非模态属性表单
- MFC我遇到的一个诡异问题
- 有没有办法给CStatic设置焦点?
- 如何更改List Control中某一个单元格的文本颜色或背景?
- 一个很简菜鸟的问题
- 我的VC在WindowXP 中编译时会出现黑色的Dos界面
- 那位仁兄有Visual Assist version 4.1.3.1236的注册吗?谢谢了,能不能借用一下。
- 如何在CFormView中加背景图画?在线等待?急急
- VC++对数据库操作支持报表生成和打印功能吗?
- 急急!如何编双击自动运行的程序?
- VC++中使用MSFlexGrid控件遇到难题,MSDN中没有帮助文档?!
- 在UNICODE下,用控件DATE TIME PICKER,只要一UPDATEDATA(TRUE)就出错
cout<<aClass::getTotal()<<" object created so far\n";