作者SweepingMonk ((((((((((()))))))))))
看板EE_DSnP
标题Re: [问题] hw1.2.2(b) 不知如何处理的error
时间Sat Mar 15 23:53:06 2008
(1)
错误:将 「const Compare」 做为 「virtual bool Compare::operator()(int, int)」
的 「this」 引数时丢弃了类型限定
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.4.234
1F:推 timrau:1. 少了const 使得const Compare不能使用operator() 03/15 23:23
2F:→ SweepingMonk:是指连 operator()(int,int) 都要宣告成const吗? 03/15 23:32
3F:推 trancewu:应该是要将function宣告成constant method 03/15 23:43
感谢楼上两位热心的回答
但是讯息变成了
错误:将 「const Compare」 做为 「virtual const bool Compare::operator()(int,
int)」 的 「this」 引数时丢弃了类型限定
好像症结并不是在那边的感觉…
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.4.234
4F:推 allencaliang:不知道你是不是把const放在bool的前面? 03/16 00:07
5F:→ allencaliang:可能要放到最後面,讲义38页有constant method的放法 03/16 00:08
6F:→ SweepingMonk:谢谢~!!跟你说的一样 现在剩linking error了,thx~ 03/16 00:22
7F:推 ric2k1:不是回传值 const, 而是 function 本身要变成 const method 03/16 01:36