From: Greger on
class QxRSSScheduleItem
{
public:
QxRSSScheduleItem( QxRSSFeeds::QxRSSFeedRep * rep );
QxRSSScheduleItem( const QxRSSScheduleItem& copy);
QxRSSScheduleItem& operator=( const QxRSSScheduleItem& copy);
friend bool operator<( QxRSSScheduleItem& si1, QxRSSScheduleItem& si2 );
friend bool operator==(QxRSSScheduleItem& si1, QxRSSScheduleItem& si2 );
QxRSSFeeds::QxRSSFeedRep * rep();
static time_t cmp_time;
private:
void copyMembers( const QxRSSScheduleItem & copy );
QxRSSFeeds::QxRSSFeedRep * Rep;
};
the above is a class of which I have a number in a vector. how do I sort the
vector?
thanks
--
Qx RSS Reader 1.2.4 released
http://www.gregerhaga.net/qxrssreader.php


From: Ulrich Eckhardt on
Greger wrote:
> class QxRSSScheduleItem
> {
> friend bool operator<( QxRSSScheduleItem& si1,
> QxRSSScheduleItem& si2 );
[...]
> };
> the above is a class of which I have a number in a vector. how do I sort
> the vector?

std::sort(vec.begin(), vec.end());

If you didn't have an operator< (of which I really wonder if it has any
natural meaning for that case) or if you want to sort it differently you
need to supply a predicate as third argument.

Uli

--
FAQ: http://ma.rtij.nl/acllc-c++.FAQ.html
 | 
Pages: 1
Prev: Introduction
Next: stupid parse error