精華區beta EE_DSnP 關於我們 聯絡資訊
※ 引述《will1220 (小崴)》之銘言: : 老師上課說每個recyclelist的element都要reuse自己的前面 : 4byte來存下一個element的位置, : 照我的想法是必須要把每一個element的位置存成一個T的形式 : 然後存給前一個element的前4byte...(不確定這樣想法對嗎) : 所以在 void pushFront(T*p)中 : 我寫了... : *p=(T)(_first); //我的意思是把_first存成一個T.... The rules for "Type casting" are actually very complicated and have a rigid definition. Please refer to C++ books or websites (e.g. MSDN) for it. A simple way to treat this kind of casting --- typeBVar = (B)(typeAVar); ^^^^^^^^^^^^^ | is to view this --------- as a calling to B's constructor by passing the parameter "typeAVar". So in your code, it is not possible to call T's constructor by passing T*. Please try other way... : _first=p; : 這樣寫compile會error... : 請問我的觀念那裡錯了嗎? : 那應該要怎麼把recyclelist的element連在一起呢? : 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.121.136.41