??C++?????????????????
???????????? ???????[ 2013/1/29 13:34:54 ] ????????
????C++??C?????????????????????????????????????????C???????????????????????????????????????????????????????C++?????????reinterpret_ cast??static_cast???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????е??????????1?????????????????????Double-Linked List?? DLL??????????????????????????????????Ρ?
class dll_t;
class dll_node_t
{
friend class dll_t;
public:
explicit dll_node_t ();
void data (void *_p_data) {p_data_ = _p_data;}
void *data () {return p_data_;}
private:
dll_node_t *prev_;
dll_node_t *next_;
void *p_data_;
};
class channel_t
{
public:
channel_t () : node ()
{
node_.data (reinterpret_cast <void *> (this));
}
private:
dll_node_t node_;
};
???????У?dll_node_t????????????????????????prev_??next_?????????????????????????????????????????????????????????p_data_?????????????????????庬????????????????????????p_data_??????????void*??????????κ???????????λ???10??11?е?data()?????????????ú???p_data_?????????
?????????е?19??29?е?????????channel_t?????dll_node_t?????Ρ???channel_t?????????У?????data()???????????????????????????this????浽????p_data_?????С??????????????data()???????p_data_?е???????????????????????????????channel_t????????????????в?δ?г?????
????????2?????????д???汾???????????????????????????????????????????????
template <typename T_NODE> class dll_t;
template <typename T_DATA> class dll_node_t
{
friend class dll_t <dll_node_t <T_DATA> >;
public:
explicit dll_node_t ();
void data (T_DATA *_p_data) {p_data_ = _p_data;}
T_DATA *data () {return p_data_;}
private:
dll_node_t *prev_;
dll_node_t *next_;
T_DATA *p_data_;
};
class channel_t
{
public:
channel_t (): node_ ()
{
node_.data (this);
}
private:
dll_node_t <channel_t> node_;
};
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11