Find Jobs
Hire Freelancers

Sort std::list in MSVC 6.0

$15-20 USD

Completed
Posted almost 19 years ago

$15-20 USD

Paid on delivery
I have the class ElementList declared as so: #include namespace FUBAR { class Element { private: int _value; public: int Value() { return _value; } } class ElementList : public std::list { void sortByValues(); } } I wish to sort ElementList's members, which are Element *'s in order of the Value() property of Element. I am using MSVC 6.0, which is broken with respect to templates, so the standard answers around the Internet don't seem to apply. Also, the fact that I'm inheriting from the template class may admittedly make things harder. So the question is how to implement this function so that it calls Value() for each element and sorts on the return value of Value(): void ElementList::sortByValues() { ...??? ... } The following at least compiles in VC 6, but it sorts the list in descending order based on the value of the pointer, and in the debugger it doesn't call the compare function. I can't see what's wrong with it. #include #include #include using namespace std ; namespace FUBAR { class Element { protected: int _value; public: int Value() { return _value; } }; class ElementList : public std::list { void sortByValues(); }; } namespace std { struct greater_ElementPtr : public greater { public: bool operator()(FUBAR::Element* pl, FUBAR::Element* pr) { return pl->Value() > pr->Value(); } }; } void FUBAR::ElementList::sortByValues() { sort(greater_ElementPtr()); } I'd be happy to implement the sort with a qsort or some other algorithm that would work on std::list in MSVC 6.0, I just don't have enough experience with stl to figure this one out. Thanks!! -Kelly ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables): a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment. b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request. 3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement). ## Platform Microsoft Visual C++ 6.0 (That it work with this Version is VERY important in this case.)
Project ID: 3773336

About the project

6 proposals
Remote project
Active 19 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$1 USD in 5 days
5.0 (13 reviews)
5.8
5.8
6 freelancers are bidding on average $8 USD for this job
User Avatar
See private message.
$12.75 USD in 5 days
4.8 (16 reviews)
5.4
5.4
User Avatar
See private message.
$5.95 USD in 5 days
5.0 (17 reviews)
4.1
4.1
User Avatar
See private message.
$8.50 USD in 5 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$8.50 USD in 5 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$8.50 USD in 5 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Springville, United States
5.0
72
Payment method verified
Member since Dec 19, 2002

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.