作者andyisman (andychen)
看板C_and_CPP
標題[問題] priority_queue 的compare
時間Sat Jan 9 10:58:06 2010
STL中的priority_queue中提供的Compare()要怎麼自訂阿?
是要寫成function, 還是要先寫一個 class 然後把 function 包進去
還是有其他的作法可以自訂compare? 請各位大大指導一下
priority_queue( input_iterator start,
input_iterator end,
const Compare& comp = Compare(),
const Container& c = Container() );
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.123.241.49
→ dp2:重載operator<,如果沒有就是寫class,重載operator() 01/09 11:34
→ dp2:寫成function也是可以的。 01/09 11:34
→ andyisman:謝謝樓上 m(_ _)m 01/09 12:30
→ johnhmj:XD 寫一個類別去繼承 priority_queue 類別~ 01/09 12:31
→ johnhmj:然後再寫這個類別的成員函式~ :P 01/09 12:32
→ nowar100:繼承STL的東西 不好吧~ XD 01/09 12:33
推 hilorrk:正常的作法是一樓那樣 絕對不推繼承STL... 01/09 19:12