作者ric2k1 (Ric)
看板EE_DSnP
標題Re: [問題] myHash.h
時間Sat Jun 20 23:56:06 2009
※ 引述《tiffiej (小小)》之銘言:
: 我compile剩下幾個error可是一直不知道為什麼 >"<
: (1)
: ../myHash.h: In instantiation of 「Hash<A, double>::iterator」:
: testHash.cpp:31: instantiated from here
: ../myHash.h:59: 錯誤:類型為 「std::pair<A, double>」 的參數的預設引數卻有類型 ?
: ../myHash.h: In member function 「bool Hash<HashKey, HashData>::iterator::operat ta = double]」:
: line 59是進去 class iterator 的第一行
這樣的 assignment 或是 initialization 是不行的...
iterator(HashNode d=0): _data(d) {}
HashNode is a pair... you cannot assign an integer to a pair.
Maybe just declare a default constructor?
iterator() {}
: =======================================================
: (2)
: testHash.cpp:32: instantiated from here
: ../myHash.h:207: 錯誤:將 「const A」 做為
: 「bool A::operator==(const A&)」 的 「this」 引數時丟棄了類型限定
: line 207是
: bool operator != (const iterator& i) const {
: return !(_data.first==i._data.first); }
: _data is a HashNode type object.
這個是我的錯!!!!!!
testHash.cpp: line 13 ---
bool operator == (const A& k) { return _data == k._data; }
請改成 ---
bool operator == (const A& k) const { return _data == k._data; }
等一下跟其他的東西一起公告更正... orz
: 有沒有人知道為什麼 T__T
: thanks.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.224.46.108
1F:推 tiffiej:thanks! 06/21 21:14