|
From: Abhijit S. <mu...@gm...> - 2002-08-18 08:48:08
|
Greets.
I'm using a vector of a structure pointer (I use dynamic allocation), like
so:
vector<PlsLine *> lines;
and PlsLine is a structure:
typedef struct _PlsLine
{
char *fn; // Full filename (c:\foo\bar.mp3)
char *filename; // Filename part only (bar.mp3)
int size; // Filesize
} PlsLine;
I need to sort this, and I call sort() like this:
sort(lines.begin(), lines.end());
However, sort() uses the comparison operators (< and >), and I can't define
them for pointers... The compiler flags this:
bool operator <(const PlsLine *&left, const PlsLine *&right)
as an error. It says it should be a class or enumerated type. I tried doing
this:
bool operator <(const PlsLine &left, const PlsLine &right)
and the compile worked, but it doesn't seem to sort.
Any work-around?
___________________________________________________________
Abhijit Shylanath
E-mail: mu...@gm... || ibr...@bi...
Web-site: http://mudeth.tripod.com/
|