Re: [問題] 請問hw1.2的第三題

看板EE_DSnP作者 (GO~~~)時間16年前 (2008/03/12 00:40), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串2/4 (看更多)
※ 引述《fairyflame (妖精火燄)》之銘言: 可以問一下 題目第四行的 A(int i =0) : _data(i) {} 是什麼意思嗎? 跟它互看了很久 還是不了解 希望不是個笨問題@@ 謝謝回答 : 題目中的: : The array size “13” is recorded around “arr’s” : location in the heap memory (hint: some bytes before arr’s address). : 是什麼意思呢? : 是指 A *arr = new A[13]; 之後 : 13這個數字會存在heap memory的某一區之中嗎@@" : 一直不知道要怎麼取出它的size說...>< : 我在main底下做了嘗試 : int *arr = new int[13]; : cout<<*(arr-1)<<endl; : 跑出來的並不是13耶@@" : 在網路上找了好久new的用法 也沒看到哪裡有提到怎麼取出array size : 可以請哪位大大幫忙開示一下嗎<(_ _)> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.40.190

03/12 08:40, , 1F
constructor of A, 傳入int(有default value 0)
03/12 08:40, 1F

03/12 08:40, , 2F
然後用i來initialize _data
03/12 08:40, 2F

03/12 13:06, , 3F
了解 謝謝~~
03/12 13:06, 3F
文章代碼(AID): #17rhNfm3 (EE_DSnP)
討論串 (同標題文章)
文章代碼(AID): #17rhNfm3 (EE_DSnP)