0

I have a struct:

struct incorrect
{
    unsigned short question;
    unsigned short answerChoice;
}

And a heap sort function:

template <typename iterator>
void heapSort(iterator begin,iterator end)
{
    make_heap(begin,end);
    sort_heap(begin,end);
}

And a function to merge questions of the vectors of the structure "incorrect". The problem I face is when I try to sort a vector of the structure "incorrect" using the following syntax:

heapSort(omitKey1.question.begin(),omitKey1.question.end());

I receive the error that question is not a member of incorrect. How can I fix this problem? (I also tried removing ".question" but that didn't seem to help)

user3093536
  • 95
  • 1
  • 7

1 Answers1

1

I think you have something like

vector<struct incorrect>omitKey1

So , use sort(omitKey1.begin(),omitKey1.end(),compare);

and in compare use : return structure1.question < structure2.question

Also , this just sorts the vector , not the heap , so i may not have answer for sorting heap .

Meanwhile look at http://www.cplusplus.com/reference/algorithm/sort_heap/

@user3093536 this should help .

Community
  • 1
  • 1
Aseem Goyal
  • 2,683
  • 3
  • 31
  • 48