sorting linked list of objects

  • I have a problem I hope somebody kan help me with. I have a number of objects of type



    that I want to put in a STL-list

    Code
    list<code *> tmp_list;

    [FONT=&quot]

    and then I want to sort them so that the code object with the biggest vector<string> files comes first

    [/FONT]

    Code
    tmp_list.sort();

    [FONT=&quot]

    But this doesn't work!? Instead I get a list sorted after int start... Can somebody see what I am doing wrong here? Or is the problem somewhere else in my program?
    [/FONT]

  • thanks for answering. I was guessing it had something to do with this...
    but what if I want to use a list of pointers, is there no way to sort the list then?

  • Zitat von phyllis

    but what if I want to use a list of pointers, is there no way to sort the list then?

    There are many - however, why are you using pointers in the first place? You don't seem to need polymorphism. To avoid copying, declare parameters as references.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!