作者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