还有一个问题
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.
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.
自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!