Quote Originally Posted by R1111
hmm why did you do "a+size" ?
It is a simpler way of writing &a[size].

Quote Originally Posted by R1111
How about this? does it seem right?
It is wrong. Once you do sort_heap, the range is no longer a heap, so you cannot subsequently call push_heap with it. Furthermore, the first argument to push_heap should be a pointer to the first element in the array. The second argument... well, I already said this before. You need to think carefully about what the arguments to push_heap should be.

Actually, why don't you pause for a moment and use std::sort instead? Get familiar with how to use std::sort. This knowledge will help you understand how to use std::make_heap and std::push_heap, but very importantly, you can easily check if you are using std::sort correctly by printing the part of the array that is in use since it is far easier to check if a range is correctly sorted than to check if a range is a heap.