Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
list<punkt> schlange; list<punkt>::iterator i; .... punkt dot(100,100); schlange.push_back(dot); .... for (i = schlange.begin();i!=schlange.end();++i); { cout<<(i->x)<<i->y; .... |
Alter Hase
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
class punkt { public: int x,y; punkt (int xneu, int yneu) { x = xneu; y= yneu; } }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include <iostream> #include <list> using namespace std; class punkt { public: int x,y; punkt (int xneu, int yneu) { x = xneu; y= yneu; } }; list<punkt> points; list<punkt>::iterator iter; int main() { punkt dot(100, 100); points.push_back(dot); for(iter = points.begin(); iter != points.end(); ++iter) { cout << iter->x << "," << iter->y << endl; } cin.get(); return 0; } |
Zitat
C-/C++-Quelltext
1 cout<<(i->x)<<i->y;
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include <iostream> #include <list> using namespace std; class punkt { public: punkt (int x = 0, int y = 0) : posx(x), posy(y){} int posx, posy; }; int main () { punkt dot (100, 100); list<punkt> schlange; list<punkt>::iterator i; schlange.push_back(dot); for (i = schlange.begin (); i != schlange.end (); ++i); { // Hier wird auch der Debug Fehler wegen dem Iterator ausgelöst cout << i->posx << i->posy; } cin.get(); return 0; } |
Zitat von »"blabla"«
Jonathan, mit dem was du sagst kann ich nicht allzu viel anfangen, kannst du mir vllt ein beispiel geben wie man es machen muss
C-/C++-Quelltext |
|
1 |
cout << i->x << i->y; |
Werbeanzeige