看板 Grad-ProbAsk 關於我們 聯絡資訊
16題的(C) Array is the most fundamental data structure. We can use it to implement any data structure, even user define structure. 答案給這個敘述是對的(如果我眼殘真的對不起大家) 只是這句話我第一個反應覺得問題超大啊... 像是 struct { int a; short b; char c; }; 是要怎麼用array做出來? 求解 thanks~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.114.123.132 ※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1516175051.A.B92.html
aggress5566: 有個東西叫pointer 01/17 15:50
kyuudonut: 搭配 Macro 應該做的出來,但別太鑽牛角尖啦 01/17 17:17
kyuudonut: 但如果是 union 應該就做不出來 XD 01/17 17:18
winiel559: 最笨的union就是用 個array做的 01/17 17:38
winiel559: 一 01/17 17:38
aggress5566: 理論上所有的container都可以 只是沒有人會這樣做而 01/17 17:39
aggress5566: 已 01/17 17:39
謝謝版友回答,只是我還是覺得這是智障題目 C++標準總共33章節 class佔4章 想要把陣列假裝成class還當真不能 struct { int a; short b; void* p; };用array來做 不僅cache的行為不一樣 對上硬體的時候也對不上 而且語言不一樣 語法也不一樣 謝謝各位回答 ※ 編輯: j5464654 (140.114.123.132), 01/18/2018 14:03:48