Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:51:04+00:00 2026-05-27T05:51:04+00:00

So I would know how to sort it if I could use a vector

  • 0

So I would know how to sort it if I could use a vector but we are required to implement it using a list. Our professor said that we can use the sort function already implemented in the list class. If it was a vector I could create a struct and then use sort from < algorithm > to go though my list but it won’t let me use that since std::list doesn’t have random access. The API says “template< class Compare >” but I don’t think that will help me.

I understand that I could use the sort function but I need to use member data to sort it. I’m sorting Points by their polar angle and I need to use the current Point that is a member of my class as the “origin” so I can’t use a static sorting comparator like I normally would.

EDIT
I’m using this as my sorting call:
sortedList.sort(sorting);

and here is my function:

bool sorting(const Point& p, const Point& q) {
    Point z = pointStack.top();
    Point u = Point(p.getX() - z.getX(), p.getY() - z.getY());
    Point v = Point(q.getX() - z.getX(), q.getY() - z.getY());
    double r = u.polarAngle();
    double s = v.polarAngle();
    if (r < s) {
            return true;
    } else { 
            return false;
    }
}

I keep getting

c:\users\wooly\documents\visual studio 2010\projects\proj5\proj5\grahamscan.cpp(20): error C3867: ‘GrahamScan::sorting’: function call missing argument list; use ‘&GrahamScan::sorting’ to create a pointer to member

since I need the top value of pointStack to do the sorting but its a member of my class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:51:04+00:00Added an answer on May 27, 2026 at 5:51 am

    You can just call the sort function directly if your value type has operator< defined.

    std::list<int> myList;
    // Do stuff to the list
    myList.sort();
    

    Or if it doesn’t you need to provide a functor that will do the comparison.

    struct MyClassComparator {
        bool operator()(const MyClass& first, const MyClass& second) const {
            // Return true if first should go before second
            return true;
        }
    };
    
    std::list<MyClass> myList;
    // Do stuff to the list
    myList.sort(MyClassComparator());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After I move (sort) one of my list items I would like to know
I found this merge sort function but i dont know how to use it.
I would like to sort the data of a core data NSSet (I know
i would to know if somebody knows a methodology or whatever that be capable
As most of you would know, if I drop a file named app_offline.htm in
Would anyone know if there are plans or extensions to Visual Studio to allow
Would anybody know why my parameter is being converted to lowercase when it hits
Would anyone know what the Win32 equivalent of opendir is (or if it even
Would anyone know how to test for the appearance of a Toast message on
i would to know how to write a profiler? What books and / or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.