作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [闲聊] 关於作业七
时间Tue Dec 4 00:18:00 2007
※ 引述《flarehunter (Range)》之铭言:
: 在constructor那边
: 大小有预设n = 0
: 这是代表把_capacity设为0吗?
: 那如果後面要变大
: 乘以二还是0耶…
: 是不是要改成 预设n = 1啊
: 然後 要不要写个解构子把 _data 的空间free掉?
Good question. 题目没讲清楚.
这是参照 STL vector 的规格, 也就是说 array 的 default constructor will set
both the size and capacity to 0. When the first element is added in
(pushed back), the capacity will become 1 or 2, depending on the platform,
and the size will be 1, of course.
You can decide the new capacity = 1 or 2, or use debugger to see how vector
is handled in your computer.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.121.132.121