Click here to Skip to main content
15,905,001 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Main Window Icon loading Pin
robert_s10-May-04 4:51
robert_s10-May-04 4:51 
Generalstd::sort( Ran first, Ran last, Cmp cmp) Pin
Laing,James9-May-04 11:17
Laing,James9-May-04 11:17 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Milton Karimbekallil9-May-04 19:31
Milton Karimbekallil9-May-04 19:31 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Maxwell Chen9-May-04 20:20
Maxwell Chen9-May-04 20:20 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Laing,James9-May-04 21:51
Laing,James9-May-04 21:51 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Milton Karimbekallil10-May-04 18:11
Milton Karimbekallil10-May-04 18:11 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Mike Dimmick10-May-04 1:43
Mike Dimmick10-May-04 1:43 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Paul Ranson10-May-04 4:14
Paul Ranson10-May-04 4:14 
Do you mean something like,
class Sort1
{
private :
    std::vector<int> v_ ;

    static bool Cmp ( const int l, const int r )
    {
        return l > r  ;
    }
public :
    Sort1 ()
    {
        v_.resize ( 10 ) ;
        for ( int i = 0; i < 10; ++i )
        {
            v_ [ i ] = i ;
        }
    }
    void DoSomething ()
    {
        std::sort ( v_.begin (), v_.end (), Cmp ) ;
    }
    void PrintV_ ()
    {
        for ( unsigned i = 0; i < v_.size (); ++i )
        {
            std::cout << v_ [ i ] << " " ;
        }
        std::cout << "\n" ;
    }
} ;

int main()
{
    Sort1 s ;
    s.PrintV_ () ;
    s.DoSomething () ;
    s.PrintV_ () ;

    return 0;
}


Or are you trying to use a member of the sortable class as the comparison function?
class Sortable
{
private :
    int val_ ;
public :
    Sortable ()
    {
    }
    static bool Cmp ( const Sortable& l, const Sortable& r )
    {
        return l.val_ > r.val_ ;
    }
} ;
...
    std::vector<Sortable> vs ;
...
    std::sort ( vs.begin (), vs.end (), Sortable::Cmp ) ;


Paul
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Laing,James10-May-04 9:42
Laing,James10-May-04 9:42 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Laing,James10-May-04 9:58
Laing,James10-May-04 9:58 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Paul Ranson10-May-04 10:39
Paul Ranson10-May-04 10:39 
GeneralRe: std::sort( Ran first, Ran last, Cmp cmp) Pin
Laing,James11-May-04 9:35
Laing,James11-May-04 9:35 
GeneralDialogs Pin
Member 6226669-May-04 10:51
Member 6226669-May-04 10:51 
GeneralRe: Dialogs Pin
Christian Graus9-May-04 13:03
protectorChristian Graus9-May-04 13:03 
Generalsnapping windows Pin
Roman Nurik9-May-04 9:19
Roman Nurik9-May-04 9:19 
GeneralRe: snapping windows Pin
KalliMan9-May-04 10:24
KalliMan9-May-04 10:24 
GeneralRe: snapping windows Pin
Antony M Kancidrowski10-May-04 2:01
Antony M Kancidrowski10-May-04 2:01 
GeneralSetFocus for a chosen Edit Control in MFC Pin
robert_s9-May-04 9:01
robert_s9-May-04 9:01 
GeneralRe: SetFocus for a chosen Edit Control in MFC Pin
KalliMan9-May-04 10:15
KalliMan9-May-04 10:15 
GeneralRe: SetFocus for a chosen Edit Control in MFC Pin
toxcct9-May-04 10:23
toxcct9-May-04 10:23 
GeneralRe: SetFocus for a chosen Edit Control in MFC Pin
robert_s9-May-04 12:07
robert_s9-May-04 12:07 
GeneralRe: SetFocus for a chosen Edit Control in MFC Pin
David Crow10-May-04 3:06
David Crow10-May-04 3:06 
Questioncd writer programming.how? Pin
Mohsen Saad9-May-04 8:59
Mohsen Saad9-May-04 8:59 
AnswerRe: cd writer programming.how? Pin
Anthony_Yio10-May-04 1:19
Anthony_Yio10-May-04 1:19 
GeneralDymanic windows Pin
Alton Williams9-May-04 4:44
Alton Williams9-May-04 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.