The following errors are always been pointing to my List.
In my class file
Point3D operator==(const Point3D &p1) const;
In my .cpp file
bool operator==(Point3D &p1, Point3D &p2)
{
if ( p1.getX() == p2.getX() && p1.getY() == p2.getY() && p1.getZ() == p2.getZ() )
return true;
else
return false;
}
In my main file
//declaration
list<Point3D> l_3D;
l_3D.unique(); <-- the error point to this
Error message
..... In member function 'void std::list<_Tp,_Alloc>::unique() [with_Tp = Point3D,_Alloc = std:: allocator<Point3D>]:
Instantiated from here
error: could not convert 'Point3D::operator==(const Point3D&) const (((const Point3D&)((const Point3D*)__next. std::_List_iterator<_Tp>::operator*[with_Tp = Point3D]())))' to 'bool'
To the kind souls out there, I thank you in advance.
In your declaration you return
Point3D, which should bebool:The above looks like you declare the operator as a member-function, bet then you implement it as a free function. You have to decide which it is. If you use a member-function, change the implementation to:
Or even better (as per @ibids comment):
Generally the signature of your definition should match the signature of your declaration.