作者ric2k1 (Ric)
看板EE_DSnP
标题Re: [问题] 有关hw4的MemRecycleList的问题
时间Mon Dec 11 01:55:33 2006
※ 引述《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