[問題] C++ STL list的begin() 傳回iterator問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
在stl_list.h裡, list<T>的begin()傳回的形態是: iterator,
iterator的本來面貌是: _List_iterator<_Tp,_Tp&,_Tp*>
但是begin()這個function的implementation是:
{ return (_Node*)(_M_node->_M_next); }
這裡_Node的形態是: _List_node
請問這到底是什麼原理? 實際傳回的形態是_List_node,
宣告的形態是_List_iterator, 這樣還可以過?
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
補充說明(Supplement):
我看的stl source code應該是SGI的蠻早的open source...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 99.57.137.146
→
12/17 15:58, , 1F
12/17 15:58, 1F
→
12/17 15:59, , 2F
12/17 15:59, 2F
→
12/17 16:00, , 3F
12/17 16:00, 3F
→
12/17 16:07, , 4F
12/17 16:07, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章