Hi, I have been searching in google for an algorithm for sort a dynamic array. I must said that the information in the Internet for sort dynamic array is very limited. However, I found bubble sort for dynamic array, but it don't wanna work. It is inside a class definition and I'm calling it from a function inside the same class.

Here is how a'm calling it: arrSort (arrayOfList, listSize);

Declaration in Public:
void arrSort(int*, int);

void file::arrSort(int* pDonate[], int s)
{
    bool swap;
    int* temp;
    do
    {
        swap = false;
        for (int count = 0; count < (s-1); count++)
        {
            if ((*pDonate[count]) > (*pDonate[count+1]))
            {
                temp = pDonate[count];
                pDonate[count] = pDonate[count+1];
                pDonate[count+1] = temp;
            }
            swap = true;
        }
    }
    while(swap);
}

Here is the error:
C:\Users\xxx\Desktop\file.h prototype for `void file::arrSort(int**, int)' does not match any in class `file'
C:\Users\xxx\Desktop\file.h void file::arrSort(int*, int)
I'm using Dev C++.

Any suggestion will be appreciate.

You've got a type problem. Always make sure you are handling the same type of things.

An int *foo; is the same as an int foo[]; But it is very different from an int *foo[]; (which is the same as an int **foo; )

Hope this helps.

Hi, if I'm right my array is int* arrayName, while the algorithm is for sort an array of type int* arrayName[]? I'm a little confused with that, then I don't be will be able to sort the dynamic array with that algorithm?

Thanks...

You've got a type problem. Always make sure you are handling the same type of things.

An int *foo; is the same as an int foo[]; But it is very different from an int *foo[]; (which is the same as an int **foo; )

Hope this helps.

Solved! Now I understand an array is an address. For that reason I don't need to have int* x [], because only with int x [] I'm pointing to a direction.

Hi, if I'm right my array is int* arrayName, while the algorithm is for sort an array of type int* arrayName[]? I'm a little confused with that, then I don't be will be able to sort the dynamic array with that algorithm?

Thanks...

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.