Can anyone tell me what I am doing wrong here, this was simply meant to show the bubble sorting method, however it fails to compile with a Variable Field Swap Declared Void Message.
One other thing, swap() is a standard algorithm which is implemented as a template
function. Instead of writing the swap() function yourself, just delete it, and #include
<algorithm> and it should work correctly.
Return 1 was my bad, I originally had no return, however I had changed the function to int and tested it that way, but with no avail. I was specifically directed to code my own swap function using pass by reference by pointers.
Return 1 was my bad, I originally had no return, however I had changed the function to int and tested it that way, but with no avail. I was specifically directed to code my own swap function using pass by reference by pointers.
in your function,you just swap two pointers. At the begining number1 pointed to number[i] and number2 pointed to number[i+1], after the swap, number1 pointed to number[i+1] and number2 pointed to number[i], but the value of number[i] and number[i+1] are not changed.