首页 新闻 搜索 专区 学院

error C2664: 'find_if' : cannot convert parameter 3 from 'bool (class Book *)' to 'bool (__thiscall *)(class Book *)'

0
悬赏园豆:5 [待解决问题]

class BookList{
public:
 friend Book;
 BookList(){ }
 void insertBook(Book* b){ bookList.push_back(b);}//插入图书

 void addItem(Book* newb,int n){//add n new books添加新书
  newb->chRemain(n);
  bookList.push_back (newb);
 }
 void chRemain(Book* b,int n){//查询剩余数量
  i=find(bookList.begin (),bookList.end (),b);
  Book * b1 =*i;
  b1->chRemain(n);
 }
 void showAll(){//显示所有图书信息
  int num=0;
  for(i=bookList.begin ();i!=bookList.end ();i++){
   Book * b =*i;
   b->getDetail();
   num++;
  }
  //cout<<"共有 "<<num<<" 种书。"<<endl;
 }
 void outBook(Book*b){//出库
  i=find(bookList.begin (),bookList.end (),b);
  Book * b1 =*i;
  b1->decrease ();
 }
 void inBook(Book*b){//入库
  i=find(bookList.begin (),bookList.end (),b); 
  Book * b1 =*i;
  b1->increase ();
 }
 int calculate(){//calculate the num of the kinds
  int num=0;
  for(i=bookList.begin ();i!=bookList.end();i++)
   num++;
  return num;
 }
 void checkBook(Book*b){//check one book's detail
  strcpy(bookName,b->getName());
  strcpy(bookAuthor,b->getAuthor());
  i=find_if(bookList.begin(),bookList.end (),sameBook);//b, 
  Book * b1 =*i;
  b1->getDetail ();
 } 
 /*find_if:条件查找
 find_if( InputIter first,InputIter last, pred)

 pred是条件谓词,可以是函数,也可以是类。
 类要重载运算符()带一个类型参数。
 当满足pred(*inputiter)==true时,返回迭代器位置,
 否则返回last。*/
/*struct sameBook

    bool operator()(Book*now)
    {
        if(strcmp(now->getName(),bookName)==0 && strcmp(now->getAuthor(),bookAuthor)==0)
   return true;
  else
   return false;
    }
};*/

 bool sameBook(Book*now){//Book*b,
  if(strcmp(now->getName(),bookName)==0 && strcmp(now->getAuthor(),bookAuthor)==0)
   return true;
  else
   return false;
 }
private:
 list<Book*>bookList;
 list<Book*>::const_iterator i;
 list<Book*>::iterator time;
 int allkind;
 char*bookName;
 char*bookAuthor;
};

加油程旭媛的主页 加油程旭媛 | 初学一级 | 园豆:195
提问于:2011-04-24 23:13
< >
分享
所有回答(1)
0

错误提示里说的很明白啦,类型不对嘛

artwl | 园豆:16526 (专家六级) | 2011-04-25 10:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册