I really can't understand why the belove code gives error. I get this error:
In function 'int* bubble_sort(int*)':
error: no matching function for call to 'swap(int*&, int&, int&)'
May someone please show me the reason?
int* bubble_sort(int arr[]) {
for(int i=0;i<sizeof(arr);i++){
for(int j=0;j<sizeof(arr);j++){
if(arr[i]>arr[j])
swap(arr, i, j );
break;
}
}
return arr;
}
void swap(int arr[], int i, int j){
int tmp=arr[i];
arr[i]=arr[j];
arr[j]=tmp;
}