0

Hi, i am making a heap sort program using a struct known as Date, anyhow i am getting an error in two lines that i cant figure out how to solve...

void dahHeap(Date a[], int i){
    int n = sizeof(a);
    int lefty = 2 * i;
    int righty = 2 * i + 1;
    int max = 0;
    if (lefty <= n && a[lefty] > a[i]) //error
        max = lefty;
    else
        max = i;
    if ((righty <= n) && (a[righty] > a[max])) //error
        max = righty;
    if (max != 1){
        Date temp = a[i];
        a[i] = a[max];
        a[max] = temp;
        dahHeap (a, max);
    }
}

i am encountering the same error in lines 6 and 10, i have tried moving around parenthesis as you can see in the differences of the code. Thank you for any of your help.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Ccuteri60
1

The problem is that, unless you define them yourself, there are no comparison operators for the Date type. The compiler does not know how to compare one Date value with another.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.