Not certain how I am to interprete the above.
no match for ‘operator!=’ in ‘this != rhs’|
Error| invalid initialization of non-const reference of type ‘Collection&’ from an rvalue of type ‘Collection* {aka Collection*}’|
I have two methods where one calls another. However,when I run the code, as is, I get the error messages above.
Collection& Collection::operator=(const Collection&& rhs)
{
if (this!= rhs)// <--- Error |no match for 'operator!=' in 'this != rhs'
{
return copy(rhs);//<---Error| invalid initialization of non-const reference of type 'Collection&' from an rvalue of type 'Collection* {aka Collection*}'
}
return *this;
}
Collection& Collection::copy(const Collection& coll)
{
}
thisis aCollection*, andrhsisconst Collection&&. You can’t!=between them. You should convertrhsto aconst Collection*via&rhs.Better yet, write an assignment operator where it doesn’t matter if you try self assignment.