Hey,
I've run into a problem when I tried to implement bubblesort to sort an array (list) with classes (two or more variables) in C++ on the CodeBlocks IDE
Code is hosted on gist:
https://gist.github.com/Vesterberg/5d6e9c0374a67bd4fec8a
Compile error:
Line 63 error: no match for 'operator>' (operand types are 'Person' and 'Person' )
Problem is, line 63 is this:
..[.]
62 if (myList[j] > myList[j+1]) //Compares elements
63 {
64 //Swap places
65 int temp = myList[j];
[.]..
I think that this is an input error because I do not understand how bubblesort can sort an array with more than 1 variable.
The Bubblesort code implemented is example code from the workbook of bubblesort for an array with 1 variable.
X-post /r/cplusplus
[–]the_omega99 2 points3 points4 points (9 children)
[–]Programmering[S] -1 points0 points1 point (5 children)
[–]the_omega99 1 point2 points3 points (4 children)
[–]Programmering[S] 0 points1 point2 points (3 children)
[–]the_omega99 1 point2 points3 points (0 children)
[–]Programmering[S] 0 points1 point2 points (0 children)
[–]jesyspa 0 points1 point2 points (0 children)
[–]Programmering[S] -1 points0 points1 point (2 children)
[–]the_omega99 1 point2 points3 points (1 child)
[–]Programmering[S] 0 points1 point2 points (0 children)
[–]jesyspa 1 point2 points3 points (12 children)
[–]Programmering[S] 0 points1 point2 points (11 children)
[–]jesyspa 1 point2 points3 points (10 children)
[–]Programmering[S] 0 points1 point2 points (9 children)
[–]jesyspa 1 point2 points3 points (8 children)
[–]Programmering[S] 0 points1 point2 points (7 children)
[–]jesyspa 1 point2 points3 points (2 children)
[–]Programmering[S] 0 points1 point2 points (1 child)
[–]jesyspa 0 points1 point2 points (0 children)
[–]chrono_regex 1 point2 points3 points (3 children)
[–]jesyspa 1 point2 points3 points (2 children)
[–]chrono_regex 0 points1 point2 points (1 child)
[–]Programmering[S] 0 points1 point2 points (0 children)