Re: help developing function
From: Johno (..._at_...)
Date: 06/19/04
- Next message: Pascal Steiss: "Problems with iterator (stack-template)"
- Previous message: Ted Harvard: "Can I program C++ on the Sinclair ZX81?"
- In reply to: John Harrison: "Re: help developing function"
- Next in thread: John Harrison: "Re: help developing function"
- Reply: John Harrison: "Re: help developing function"
- Reply: Thomas Matthews: "Re: help developing function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 19 Jun 2004 09:48:24 GMT
Thanks John,
I've got it working. I now have to write a comparison function that when
given two pointers to Digital_camera objects decides which of the two should
come first in sorted order. The sorting order is in decreasing order of
megapixels. Where megapixels are the same, in increasing alphabetical order
of make. Where megapixels and make are the same, in increasing alphabetical
order of model. When the function is complete I'm required to use it with
STL's sort() algorithm.
The code for the function is as follows; however, it's not working. Can I
please ask you to have a look at it and tell me what I need to do to get it
working correctly.
Thanks,
bool compare operator() (Digital_camera* a, Digital_camera* b)
{
double first = a.getMegapixels();
double second = b.getMegapixels();
string third = a.getMake();
string fourth = b.getMake();
string fifth = a.getModel();
string sixth = b.getModel();
if (first != second)
{
return (first < second);
}
else if (third != fourth);
{
return (third < fourth);
}
else
{
return (fifth < sixth);
}
}
- Next message: Pascal Steiss: "Problems with iterator (stack-template)"
- Previous message: Ted Harvard: "Can I program C++ on the Sinclair ZX81?"
- In reply to: John Harrison: "Re: help developing function"
- Next in thread: John Harrison: "Re: help developing function"
- Reply: John Harrison: "Re: help developing function"
- Reply: Thomas Matthews: "Re: help developing function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|