J
Jim
Hi,
I'm trying to sort a vector using
sort(corelist.begin(),corelist.end());
so I've provided a method to overload the < operator in the file, like
so, but it isn't a class member and the code which uses it is in
another file containing a class which inherits from this class:
bool operator< ( const Core& a, const Core& b) {
return a.getdistance() < b.getdistance();
}
Only problem is I get a const discard qualifiers error, which seems
very annoying. It seems to make me choose whether I want to hide my
code's variables or have them const. Removing the const seems to allow
the program to compile but there are a lot of errors (top line of
which shown below). getdistance just returns a double and I'm using
gcc. I haven't got a == operator in the code, but think I may possibly
need one.
Any help would be gratefully received
James
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:
In function 'void std:artial_sort(_RandomAccessIterator,
_RandomAccessIterator, _RandomAccessIterator) [with
_RandomAccessIterator = __gnu_cxx::__normal_iterator<Core*,
std::vector<Core, std::allocator<Core> > >]':
I'm trying to sort a vector using
sort(corelist.begin(),corelist.end());
so I've provided a method to overload the < operator in the file, like
so, but it isn't a class member and the code which uses it is in
another file containing a class which inherits from this class:
bool operator< ( const Core& a, const Core& b) {
return a.getdistance() < b.getdistance();
}
Only problem is I get a const discard qualifiers error, which seems
very annoying. It seems to make me choose whether I want to hide my
code's variables or have them const. Removing the const seems to allow
the program to compile but there are a lot of errors (top line of
which shown below). getdistance just returns a double and I'm using
gcc. I haven't got a == operator in the code, but think I may possibly
need one.
Any help would be gratefully received
James
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/bits/stl_algo.h:
In function 'void std:artial_sort(_RandomAccessIterator,
_RandomAccessIterator, _RandomAccessIterator) [with
_RandomAccessIterator = __gnu_cxx::__normal_iterator<Core*,
std::vector<Core, std::allocator<Core> > >]':