Re: help developing function

From: Johno (..._at_...)
Date: 06/19/04


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);

}

}



Relevant Pages

  • Re: Operator overloading in C
    ... All development of C as an independent language has ... making any changes or improvements to the standard ... The lack of a counted string data structure, ... Pointers can't be used for arg1 or arg2. ...
    (comp.std.c)
  • Re: help developing function
    ... I now have to write a comparison function that when ... > given two pointers to Digital_camera objects decides which of the two should ... Where megapixels are the same, ... C++ Faq: http://www.parashift.com/c++-faq-lite C Faq: http://www.eskimo.com/~scs/c-faq/top.html alt.comp.lang.learn.c-c++ faq: ...
    (comp.lang.cpp)
  • Re: get text from listbox
    ... Dim nCount As Long ... Dim Buffer As String ... The first character is the low byte of the low word of the DWORD item data ... To prove that these are pointers get the item data of the list items as ...
    (microsoft.public.vb.winapi)
  • Re: Comments requested: brief summary of C
    ... ``A char holds a single byte. ... ``A string is a contiguous sequence of characters terminated ... pointed to by city. ... pointers and arrays are often used ...
    (comp.lang.c)
  • Re: Another Understanding Pointers Question
    ... > string functions to test. ... Again, why increment j? ... a good use of pointers. ... darrell at cs dot toronto dot edu ...
    (comp.lang.c)