| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5172 人关注过本帖
标题:myajax95斑竹,我要求你把那个帖子解开
只看楼主 加入收藏
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
还有一个问题
int *p = new int(0);

int *pt = new int[5];

两个 new 是否是同一种东西

new is just an operator, how it will be used, dependent on that how you used it.

the first
int *p = new int(0); 4 Byte allocation, and initialized with value 0; p will be assigned the address, under this address will this value 0 saved.

the second
int * pt = new int [5]; dynamically allocation for an integer array with 5 integer. After allocation, pt get the first address of this allocation. because every integer need 4 Byte, so 5 integer need 20 Byte, that mean the allocation is 20 Byte allocation. and After the allocation the first address will be assigned to pt.



自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-07-25 00:53
穆扬
Rank: 1
等 级:禁止发言
帖 子:1910
专家分:0
注 册:2006-6-1
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

2006-07-25 01:00
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
穆扬,

don't make it confuse.

int * p = new int[5]; you should know p get an address, just an address, for example 3000, but p is not from type int *, p here is an point to an array.

The important is that you can image what in really stand. That mean, you should view the physicalishe image.

自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-07-25 01:07
穆扬
Rank: 1
等 级:禁止发言
帖 子:1910
专家分:0
注 册:2006-6-1
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

2006-07-25 01:09
穆扬
Rank: 1
等 级:禁止发言
帖 子:1910
专家分:0
注 册:2006-6-1
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

2006-07-25 01:13
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
穆扬,

C++ there is just one C++ not two, or more. Why you will think, there is not only one C++? I think you need learn it.

世界上究竟有没有不懂c的c++的“高手” I think, no , there is no C++ master who don't know C, because C++ include C. Maybe C++ Master can not write good code in C. And there is really too more C Master who don't know C++ any more.


自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-07-25 01:15
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 
穆扬,

a pointer will get an address, and something more, a pointer has still a type. As programmer, you should see that, and more things you should get is, you should get an image what really in physical is. That is the difference between an normal programmer and a master.

A master can image, what happend after a statement, not just datetype, but also what in physicalisch level happend. When you can do that, then you can write the code, what you want, and safe and efficient.

自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2006-07-25 01:20
穆扬
Rank: 1
等 级:禁止发言
帖 子:1910
专家分:0
注 册:2006-6-1
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

2006-07-25 01:24
穆扬
Rank: 1
等 级:禁止发言
帖 子:1910
专家分:0
注 册:2006-6-1
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

2006-07-25 01:29
song4
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:38
帖 子:1533
专家分:4
注 册:2006-3-25
收藏
得分:0 
自己的new malloc在堆

嵌入式 ARM 单片机 驱动 RT操作系统 J2ME LINUX  Symbian C C++ 数据结构 JAVA Oracle 设计模式 软件工程 JSP
2006-07-25 08:06
快速回复:myajax95斑竹,我要求你把那个帖子解开
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.119971 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved