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.

Recommended Answers

All 2 Replies

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.

oh that makes perfect sense...thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.