class book{
public:
void setNameOfAuthor(string nameOfAuthor);
string getNameOfAuthor();
void setBookId(int bookid);
int getBookId();
bool operator==(const book& rhs)const;
const int operator*()const;
private:
string m_nameOfAuthor;
int m_bookId;
};
class bms{
private:
vector<book> m_books;
public:
void addNewBook(book& booktoadd);
void deleteBook();
void displayBook();
};
bool book::operator==(const book& rhs)const{
return m_bookId == rhs.m_bookId;
}
const int book::operator*()const{
return m_bookId;
}
void bms::deleteBook(){
int booid;
auto itr = find(m_books.begin(), m_books.end(), booid); ------>issue is here
if( itr != m_books.end()){
m_books.erase(itr);
}else{
cout<<"book is not found!!"<<endl;
}
}
im working on book management system project , trying to delete a book in find i get error as
Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/algorithm:919:22: error: invalid operands to binary expression ('book' and 'const int')
if (*__first == __value_)
so i tried overloading == operator and *operator but couldnt resolve my issue , not getting where im doing wrong
in find if i debug i think issue is
find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
{
for (; __first != __last; ++__first)
if (*__first == __value_)-------------> issue seems to be hereis here
break;
return __first;
}
as i overloaded == operator so comparasion should happen between int and int im not getting why comparsion is happening between book object and int. please help