作者love20123 (傻瓜)
看板EE_DSnP
标题[问题] hw1.2.p2b
时间Wed Oct 7 18:56:53 2009
照着老师上课的指示
class Compare
{
...
virtual bool operator()(int,int)=0;
};
class Less : public Compare
{
bool operator()(int i, int j){
...
}
};
void selectionSort(vector<int>& array, const Compare& compare)
{
...
}
可是最後却出现了两行错误讯息
1. In function 『void selectionSort(std::vector<int>,
std::allocator<int> >&, const Compare&)』
2. 错误:将『const Compare』做为『virtual bool Compare::operator()
(int,int)』的『this』引数时丢弃了类型限定
DEBUG了好久 还是不知道怎麽办 最後决定吃饭去
希望老师或强者可以解惑一下
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.4.235
1F:推 yangjiunru:bool operator()必须要是const member function才能被 10/07 19:18
2F:→ yangjiunru:const object呼叫 10/07 19:18
3F:→ yangjiunru:可以google一下const member function 10/07 19:19
4F:推 ric2k1:正解 10/07 19:41
5F:→ love20123:感谢强者书豪解决了我的问题 10/07 21:46