I would like to know why i am unable to create a set.
I am getting the following error
Here is my codes.
Point.cpp My Point class
bool Point::operator<(const Point& p2)const {
return p21.length < p2.getScalarValue();
}
bool Point::operator>(const Point p2) {
bool result;
result = length > p2.getScalarValue();
return result;
}
and in my main.cpp
set<Point> s_p2;
Point tempp2;
s_p2.insert(tempp2);
After following your inputs, i have edited the codes and i have the following error
Point.cpp:56:46: error: passing ‘const Point’ as ‘this’ argument of ‘double Point::getScalarValue()’ discards qualifiers [-fpermissive]
Is this because i got two comparing statements ?
Managed to solve it. I need to make my get getScalarValue() const also.
as it only returns the value.
It complies and runs without error.