实验验证stack和heap中是否被设初值
2024-08-23 12:52:11
#include <iostream>
#include <stdlib.h> using namespace std;
class Foo
{
public:
int i;
float f;
char *cp; }; int main()
{
Foo f1;
if(f1.cp == 0) cout <<" in stack,f1.cp is null "<< endl;
cout<< f1.i << " " << f1.f <<" "<<f1.cp << endl; Foo *pf = new Foo();
if(pf->cp == 0) cout <<" in heap,pf.cp is null "<< endl;
cout << pf->i << " " << pf->f << " "<< pf->cp <<endl; return 0;
}
/work/ctest/insideTheC++ObjectModel$ ./1
770374040 4.55997e-41 H�l$�L�d$�H�-
in heap,pf.cp is null
0 0
最新文章
- C#汉字转拼音(支持多音字)
- SqlServer删除表中重复记录
- [Asp.net]通过uploadify将文件上传到B服务器的共享文件夹中
- How to get the Current Controller Name, Action, or ID in ASP.NET MVC
- c++ 中 delete p与 delete []p的区别
- RedHat6.6更新Centos6yum源
- [原创]谷歌插件 - YE搜图助手(YeImageFinder)
- SkyEye的使用
- IPayablebillItf
- 【Java】Java6 WebService的发布
- ‘for’ loop initial declarations are only allowed in C99 mode
- Oracle修改字段长度以及计算天数
- 543. Diameter of Binary Tree
- C++求出旋转数组的最小数字
- Ubuntu Server无线上网
- Linux centos7系统下svn的安装与配置
- 利用Eclipse构建SpringMVC项目
- 任务型对话(一)—— NLU(意识识别和槽值填充)
- 字符编码:Unicode和UTF-8之间的关系
- List接口和Set接口和Map接口的of方法