Ich wollte eine Liste aus den unten angegebenen Structs sortieren.
Leider erhalte ich das die ganz unten Zitierten Compiler-Fehler.
Was mache ich falsch? / geht das vll auch einfacher?
Alles anzeigen
Leider erhalte ich das die ganz unten Zitierten Compiler-Fehler.
Was mache ich falsch? / geht das vll auch einfacher?
Quellcode
- #include <iostream>
- #include <list>
- #include <functional>
- struct ABC
- {
- int begin, end;
- };
- struct less_ABC
- : public binary_function<ABC, ABC, bool>
- {
- bool operator()(const ABC& x, const ABC& y) const {return x.begin < y.begin;}
- };
- int main()
- {
- std::list<ABC> myList;
- ABC dummy;
- dummy.begin = 5;
- dummy.end = 10;
- myList.push_back(dummy);
- dummy.begin = 10;
- dummy.end = 15;
- myList.push_back(dummy);
- dummy.begin = 15;
- dummy.end = 20;
- myList.push_back(dummy);
- myList.sort(less_ABC);
- }
mingw32-make -f makefile all
g++ -c main.cpp
main.cpp:11: error: expected template-name before '<' token
main.cpp:11: error: expected `{' before '<' token
main.cpp:11: error: expected unqualified-id before '<' token
main.cpp:11: error: expected `,' or `;' before '<' token
main.cpp: In function `int main()':
main.cpp:37: error: invalid use of undefined type `struct less_ABC'
main.cpp:11: error: forward declaration of `struct less_ABC'
mingw32-make: *** [main.o] Error 1
There are only 10 types of people in the world: Those who understand binary, and those who don't.
Download meines ersten Spiels:HIER
Über Feedback würde ich mich freuen
Download meines ersten Spiels:HIER
Über Feedback würde ich mich freuen
