hallo,
ich musste jetzt einen älteren Code ausgraben, der früher mal funktioniert hat (eventuelle c+p Fehler nicht gefunden).
Der Compiler meckert über :
Code:
void bubblesort(VTYPE *array, int length) {
^
sketch_mar08a:7: error: 'VTYPE' was not declared in this scope
sketch_mar08a:7: error: 'array' was not declared in this scope
void bubblesort(VTYPE *array, int length) {
^
sketch_mar08a:7: error: expected primary-expression before 'int'
void bubblesort(VTYPE *array, int length) {
^
exit status 1
variable or field 'bubblesort' declared void
was ist falsch?
dies ist der Code:
Code:
//---------------------------------------------------------
// Bubble Sort
//---------------------------------------------------------
template <typename VTYPE>
void bubblesort(VTYPE *array, int length) {
VTYPE tmp;
for (int i=0; i<length-1; i++) {
for (int j=0; j<length-i-1; j++) {
if (array[j] > array[j+1]) {
tmp = array[j];
array[j] = array[j+1];
array[j+1] = tmp;
}
}
}
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Lesezeichen