看板 EE_DSnP 關於我們 聯絡資訊
由於overloaded = 的prototype是 iterator& operator = (const iterator& i) 在ADT member function中如果要宣告並初始化iterator 若這樣寫 iterator it = this.begin(); 會有error: request for member 'begin' in 'this', which is of non-class type 'DList<AdtTestObj>* const' 我猜想是因為 = 需要reference to a const iterator 但begin return 的只是普通iterator 這樣寫也會有相同錯誤 iterator it(this.begin()); 但如果要使用overloaded = 還要修改右邊成為const的話,感覺有點麻煩 請問有沒有能讓 = 順利使用的方法?? 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.44.162
yangjiunru:應該是this->begin() or begin() 05/20 13:56
wanga10219:因為this 是指標 05/20 20:19