I programmed in C for a while and now I'm new to C++. I have to replace the for-loops in a C-Programm with the range-based for loops of C++11. This is the actual code:
void sort1(int num[], int start, int end) {
int finished = 0, i;
while(!finished) {
finished = 1;
for(i=start ; i<end ; i++) {
if(num[i] > num[i+1]) {
swap(num, i, i+1);
finished = 0;
}
}
}
}
And this is what I changed it to:
void sort1(int num[], int start, int end) {
bool finished = 0;
while(!finished) {
finished = 1;
for(int i : num) {
if(i > i+1) {
swap(num, i, i+1);
finished = 0;
}
}
}
}
I cannot even compile it, it gives me the error: error: no matching function for call to 'begin(int*&)'
(Sorry if my english is a bit weird :D)