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
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
void CAuto::Move (float time) { Vec2d direction (sin (_angle), cos (_angle)); // Bei 0° ist das Y. _location += time * _speed * direction; } void CAuto::OnTurnLeft (float time) { _angle = ::fmodf (_angle - (TURN_SPEED * time), 2.0f * PI); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class CVector { public: float x, y; //Vektorkomponenten CVector(){} //Standardkonstruktor (tut nichts) CVector(const CVector& v) : x(y.x), y(v.y){} //Kopierkonstruktor CVector(const float vx, const float vy) : x(vx), y(vy) //Konstruktor, der die angegeben Vektorkomponenten einsetzt { } inline CVector operator + (const CVector& a, const CVector& b) { return CVector(a.x + b.x , a.y + b.y); } }; |
Quellcode |
|
1 2 |
c:\Dokumente und Einstellungen\asdfasdf\Eigene Dateien\Visual Studio Projects\MoveVect2D\CVector.hpp(15): error C2804: Binärer Operator '+' hat zu viele Parameter c:\Dokumente und Einstellungen\asdfasdf\Eigene Dateien\Visual Studio Projects\MoveVect2D\CVector.hpp(15): error C2333: 'CVector::operator`+'': Fehler in Funktionsdeklaration; Funktionstext wird übersprungen |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class CVector { public: float x, y; //Vektorkomponenten CVector(){} //Standardkonstruktor (tut nichts) CVector(const CVector& v) : x(y.x), y(v.y){} //Kopierkonstruktor CVector(const float vx, const float vy) : x(vx), y(vy) //Konstruktor, der die angegeben Vektorkomponenten einsetzt { } inline CVector operator+ (const CVector& a, const CVector& b) { return CVector(a.x + b.x , a.y + b.y); } }; |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class CVector { public: float x, y; //Vektorkomponenten CVector(){} //Standardkonstruktor (tut nichts) CVector(const CVector& v) : x(y.x), y(v.y){} //Kopierkonstruktor CVector(const float vx, const float vy) : x(vx), y(vy) //Konstruktor, der die angegeben Vektorkomponenten einsetzt { } inline CVector& operator+ (const CVector& a, const CVector& b); }; |
C-/C++-Quelltext |
|
1 2 3 4 5 |
cpp Datei: inline CVector::CVector& operator+ (const CVector& a, const CVector& b); { return CVector(a.x + b.x , a.y + b.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 |
class CVector { public: float x, y; //Vektorkomponenten CVector(){} //Standardkonstruktor (tut nichts) CVector(const CVector& v) : x(y.x), y(v.y){} //Kopierkonstruktor CVector(const float vx, const float vy) : x(vx), y(vy) //Konstruktor, der die angegeben Vektorkomponenten einsetzt { } CVector& operator += (const CVector& v) { x += v.x; y+= v.y; return *this; } }; inline CVector operator + (const CVector& a, const CVector& b) { return CVector(a.x + b.x , a.y + b.y); } |
Anonymous
unregistriert
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 |
class CVector { public: float x, y; //Vektorkomponenten CVector(){} //Standardkonstruktor (tut nichts) CVector(const CVector& v) : x(v.x), y(v.y){} //Kopierkonstruktor CVector(const float vx, const float vy) : x(vx), y(vy) //Konstruktor, der die angegeben Vektorkomponenten einsetzt { } CVector& operator += (const CVector& v) { x += x; y+= y; return *this; } }; inline CVector operator + (const CVector& a, const CVector& b) { return CVector(a.x + b.x , a.y + b.y); } |
Alter Hase
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 |
class CVector { public: float x, y; //Vektorkomponenten CVector(){} //Standardkonstruktor (tut nichts) CVector(const CVector& v) : x(v.x), y(v.y){} //Kopierkonstruktor CVector(const float vx, const float vy) : x(vx), y(vy) //Konstruktor, der die angegeben Vektorkomponenten einsetzt { } CVector& operator += (const CVector& v) { x += v.x; y+= v.y; return *this; } CVector operator + (const CVector& v) { return CVector( x + v.x, y + v.y ); } }; |
Werbeanzeige