CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Jul 2008
    Posts
    17

    Difficulties Using STL sort on Array of Objects

    My goal was to sort a list of outputted vectors by length. I ended up trying to do this by creating a simple class that stored the vector, and the length of the vector. I then overloaded the < operator so that I could use the STL sort function. I had all kind of problems. I was able to make them go away when I stopped using dynamic allocation (dynamic allocation was used so that the vectors were d-dimensional, I then fixed their dimension at 3). I have attached the code that uses dynamic allocation (note that I have fixed the dimension at 3 for simplicity), and hence doesn't work. All that's required to get my code to work is to change the statement in dBallMember.h from int* vector to int vector[3] and removing all new and delete statements as appropriate. I just don't understand what I haven't done right. Help?
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured