expression list treated as compound expression in functional cast [-fpermissive]
22:49 11 Mar 2014
#include 
#include 

using namespace std;

typedef bool (*compare)(int,int);

void SelectionSort(int *inArray,int size, compare)
{
        for (int loop = 0 ; loop < size ; loop++)
        {
                for(int j = loop+1 ; j < size ; j++)
                {
                        if (compare(inArray[j],inArray[loop]))
                                swap(inArray[loop],inArray[j]);
                }
        }
}

void display(int *inArray,int size)
{
        cout << "Printing the array " << "\n" << endl;
        for(int loop = 0; loop < size; loop++)
        {
                cout << inArray[loop] << endl;
        }

}

bool ascending(int a , int b)
{
        if(a < b)
                return true;
        else
                return false;
}

bool descending(int a,int b)
{
        if (a > b)
                return true;
        else
                return false;
}


int main()
{

        compare c1 = ascending;
        compare c2 = descending;
        int pList[5] = {50,40,30,20,10};

        display(pList,5);
        SelectionSort(pList,5,c1);
        display(pList,5);
        SelectionSort(pList,5,c2);
        display(pList,5);

}

And the command I used to compile:

$ g++ test.cpp
test.cpp: In function 'void SelectionSort(int*, int, compare)':
test.cpp:14:40: error: expression list treated as compound expression in functional cast [-fpermissive]
test.cpp:14:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Why is the error appearing. I am from C background.The above I think is perfectly valid in 'C' Why is this happening in C++?

c++