|
|
|
|
|
|
|
|
|
|
|
|
|
|
I am just curious to why i have to define an overload like this: bool operator==(const char* title) const { return sTitle == title; } }; when u have already defined this outside of the class: bool operator == (Book const& lhs, Book const& rhs) { return lhs.sTitle == rhs.sTitle; } |
why i have to define an overload like this: bool operator==(const char* title) const |
vector <Book>::iterator p = find(v.begin(), v.end(), "C++ primer" );
when u have already defined this outside of the class: |
if i don't use the line: friend bool operator == (Book const& lhs, Book const& rhs); will it be the same if i write this : lass Book{ . . . bool operator == (Book const& lhs, Book const& rhs) { return lhs.sTitle == rhs.sTitle; } |
i have defined bool operator == (Book const& lhs, Book const& rhs) { return lhs.sTitle == rhs.sTitle; } inside the class Book and it is giving me the error too many parameters but u are using friend bool operator == (Book const& lhs, Book const& rhs); which also takes on two parameters inside class Book and it works ? |
also can i change const * char to string inside this function : so: bool operator==(const char* title) const { return sTitle == title; } becomes bool operator==(string title) const { return sTitle == title; } |