<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[warum stürzt das ab(push_back bei vector)]]></title><description><![CDATA[<p>Also ich hab mir das ganze mit dem debugger angeschaut aber keine undefinierten variablen/pointer oder speicherfehler gefunden.</p>
<pre><code class="language-cpp">void PSpawner::frame()
{
	if(cInterval &lt; sAmount) //wenn weniger partikel ausgestoßen wurden, als insgesamt ausgestoßen werden sollen
	{
		if(sInterval &gt; 0)//wenn der interval größer 0 ist
		{
			Uint32 cTime = SDL_GetTicks() - startTime;//alter des spawners
			int cDif = (int)(cTime/(float)sInterval) - cInterval ;//anzahl der abgelaufenen intervalle seit dem letzten aufruf von frame()
			cInterval += cDif;//intervalle auf abgelaufene intervalle addieren
			while(cDif &gt; 0)//alle ausstehenden intervalle durchlaufen
			{
				SDL_Surface *t;
				t = sprite;
				t-&gt;refcount++; //partikel kopieren (surface)
				Particle pt(t, gravity, replaceColor, lifetime, pos.x, pos.y, direction.x, direction.y); // neuen partikel mit den gegebenen parametern erstellen
				if(hasFade)//irrelevant
					pt.addFadeStruct(fadeS);
				pList-&gt;push_back(pt);//auf die liste der partikel pushen (der pointer auf die liste wird beim erstellen des spawners übergeben.)

				cDif--;//is klar
			}
		}
	}
}
</code></pre>
<p>das ist ein partikelspawner, der in intervallen partikel ausstößt.<br />
nachdem 1(glaube ich) partikel ausgestoßen wurde, beendet sich das programm bei der zeile pList-&gt;push_back(pt); (beim nächsten ausstoß)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/186431/warum-stürzt-das-ab-push_back-bei-vector</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 09:53:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/186431.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Jul 2007 22:02:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Sun, 08 Jul 2007 22:11:41 GMT]]></title><description><![CDATA[<p>Also ich hab mir das ganze mit dem debugger angeschaut aber keine undefinierten variablen/pointer oder speicherfehler gefunden.</p>
<pre><code class="language-cpp">void PSpawner::frame()
{
	if(cInterval &lt; sAmount) //wenn weniger partikel ausgestoßen wurden, als insgesamt ausgestoßen werden sollen
	{
		if(sInterval &gt; 0)//wenn der interval größer 0 ist
		{
			Uint32 cTime = SDL_GetTicks() - startTime;//alter des spawners
			int cDif = (int)(cTime/(float)sInterval) - cInterval ;//anzahl der abgelaufenen intervalle seit dem letzten aufruf von frame()
			cInterval += cDif;//intervalle auf abgelaufene intervalle addieren
			while(cDif &gt; 0)//alle ausstehenden intervalle durchlaufen
			{
				SDL_Surface *t;
				t = sprite;
				t-&gt;refcount++; //partikel kopieren (surface)
				Particle pt(t, gravity, replaceColor, lifetime, pos.x, pos.y, direction.x, direction.y); // neuen partikel mit den gegebenen parametern erstellen
				if(hasFade)//irrelevant
					pt.addFadeStruct(fadeS);
				pList-&gt;push_back(pt);//auf die liste der partikel pushen (der pointer auf die liste wird beim erstellen des spawners übergeben.)

				cDif--;//is klar
			}
		}
	}
}
</code></pre>
<p>das ist ein partikelspawner, der in intervallen partikel ausstößt.<br />
nachdem 1(glaube ich) partikel ausgestoßen wurde, beendet sich das programm bei der zeile pList-&gt;push_back(pt); (beim nächsten ausstoß)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321077</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Sun, 08 Jul 2007 22:11:41 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 05:13:01 GMT]]></title><description><![CDATA[<p>wo ist pList deklariert also der vector?<br />
Wie hast du in deklariert?<br />
Hat Particel ein Copy C-tor?<br />
Übergibst du auch richtig den Pointer des Vectors?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321109</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Mon, 09 Jul 2007 05:13:01 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 06:02:18 GMT]]></title><description><![CDATA[<p>BorisDieKlinge schrieb:</p>
<blockquote>
<p>wo ist pList deklariert also der vector?<br />
Wie hast du in deklariert?<br />
Hat Particel ein Copy C-tor?<br />
Übergibst du auch richtig den Pointer des Vectors?</p>
</blockquote>
<p>nein particle hat keinen copy ctor, worfür bräuchte man den hier ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321128</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 06:02:18 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 06:09:24 GMT]]></title><description><![CDATA[<p>pixartist schrieb:</p>
<blockquote>
<p>nein particle hat keinen copy ctor, worfür bräuchte man den hier ?</p>
</blockquote>
<p>Keine Ahnung, dazu hast du nicht genug von Particle gezeigt. Da aber Particle im Konstruktor einen Zeiger mit Referenzzählung entgegennimmt, könnte es sein, dass du einen brauchst. Der Fehler steckt IMHO nicht in dem gezeigten Code, sondern irgendwo in Particle, oder an ganz anderer Stelle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321130</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 09 Jul 2007 06:09:24 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 06:18:11 GMT]]></title><description><![CDATA[<p>Dadurch das du PArtikel Objekte lokal in dem while block erzeugt:</p>
<pre><code class="language-cpp">Particle pt(t, gravity, replaceColor, lifetime, pos.x, pos.y, direction.x, direction.y); // neuen partikel mit den gegebenen parametern erstellen
</code></pre>
<p>und dann &quot;pt&quot; in den vector Pushed, erstell der vector eine Kopy von pt und haut legt dies im vector ab..</p>
<p>von dem gezeigten code her hast du vector so delaiert?</p>
<pre><code class="language-cpp">std::vector&lt;Particle&gt; *Liste;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1321137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321137</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Mon, 09 Jul 2007 06:18:11 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 08:18:23 GMT]]></title><description><![CDATA[<p>Besser wäre es wohl so</p>
<pre><code class="language-cpp">pList-&gt;push_back(Particle(t, gravity, replaceColor, lifetime, pos.x, pos.y, direction.x, direction.y));
if(hasFade)//irrelevant
     pList-&gt;back().addFadeStruct(fadeS);
</code></pre>
<p>Da spart man sich eine Kopie. Den CopyCtor braucht man natürlich trotzdem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321214</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 09 Jul 2007 08:18:23 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 09:46:14 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Besser wäre es wohl so</p>
<pre><code class="language-cpp">pList-&gt;push_back(Particle(t, gravity, replaceColor, lifetime, pos.x, pos.y, direction.x, direction.y));
if(hasFade)//irrelevant
     pList-&gt;back().addFadeStruct(fadeS);
</code></pre>
<p>Da spart man sich eine Kopie. Den CopyCtor braucht man natürlich trotzdem.</p>
</blockquote>
<p>achso zum pushen von objekten in nen vektor braucht das objekt nen copy ctor ? interessant, wusste ich nicht.<br />
was mich daran wundert ist, dass ich ja einen partikel pushen konnte! (der wurde dann auch dargestellt)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321283</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 09:46:14 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 09:52:29 GMT]]></title><description><![CDATA[<p>pixartist schrieb:</p>
<blockquote>
<p>BorisDieKlinge schrieb:</p>
<blockquote>
<p>wo ist pList deklariert also der vector?<br />
Wie hast du in deklariert?<br />
Hat Particel ein Copy C-tor?<br />
Übergibst du auch richtig den Pointer des Vectors?</p>
</blockquote>
<p>nein particle hat keinen copy ctor, worfür bräuchte man den hier ?</p>
</blockquote>
<p>Wenn du ihn nicht explizit abgeschafft hast, hat 'particle' einen Copy-Ctor. Das Problem ist, daß dieser vom Compiler bereitgestellte CCtor nicht immer korrekt funktioniert (der erzeugt eine flache Kopie aller Member - und wenn du irgendwelche dynamisch verwalteten Daten hast, erzeugst du dir damit nur Probleme<sup>*</sup>).</p>
<p><sup>*</sup> im Extremfall werden die Daten doppelt freigegeben, was zum Zusammenbruch des Heap führen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321295</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321295</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 09 Jul 2007 09:52:29 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 09:58:46 GMT]]></title><description><![CDATA[<p>Gleich mal ausprobieren, hatte eben auch das Problem das das pushen von eigenen Objekten zu Speicherfehlern führte.</p>
<p>Dynamisch ist dort nur ein Vektor der eben Objekte der Besitzerklassses aufnehmen kann.</p>
<pre><code class="language-cpp">class Hud {

std::vector&lt;Hud&gt; Kinder;
public:
void insert(Hud Kind){ this-&gt;Kinder.push_back(Kind);};
}
</code></pre>
<p>wäre dies ein solcher Fall für nen eigenen CCtor? Oder liegt hier das Problem eher darin das sich dieKatze in den Schwanz beisst</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321298</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321298</guid><dc:creator><![CDATA[GreyHound]]></dc:creator><pubDate>Mon, 09 Jul 2007 09:58:46 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:01:53 GMT]]></title><description><![CDATA[<p>genau , und diese vector muss du über den kopy Konstruktor kopieren (Tiefe kopie)?</p>
<p>Ich frage mich allerding wie sieht der Automatisch Kopierte Kopy C-Tor von &quot;hud&quot; aus?</p>
<p>Wenn er so aussieht, müssten die objekt ohne weiterere automatisch kopiert werden ??</p>
<pre><code class="language-cpp">Hud::Hud(const Hud &amp; oScr){

 this-&gt;Kinder = oScr.Kinder;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1321307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321307</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:01:53 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:04:10 GMT]]></title><description><![CDATA[<p>Wenn Hud wirklich nichts weiter enthält, braucht es keinen besonderen Copy-CTor, weil der automatisch generierte das Richtige tut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321309</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:04:10 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:12:05 GMT]]></title><description><![CDATA[<p>GreyHound schrieb:</p>
<blockquote>
<p>wäre dies ein solcher Fall für nen eigenen CCtor? Oder liegt hier das Problem eher darin das sich dieKatze in den Schwanz beisst</p>
</blockquote>
<p>In dem Fall kommst du mit dem impliziten CTor völlig aus (der vector&lt;&gt; enthält zwar dynamische Daten, aber das ist sein Problem).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321323</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321323</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:12:05 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:16:44 GMT]]></title><description><![CDATA[<p>aha, dann sieht der Autmoatisch genierierte quaise immer so aus:</p>
<pre><code class="language-cpp">Klasse::Klasse(const Klasse &amp;oQuelle){

this-&gt;V_1= oQuelle.V_1;
this-&gt;V_2= oQuelle.V_2;
this-&gt;V_3= oQuelle.V_3;
.
.
.
.
this-&gt;V_N= oQuelle.V_N;
</code></pre>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321328</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:16:44 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:21:18 GMT]]></title><description><![CDATA[<p>BorisDieKlinge schrieb:</p>
<blockquote>
<p>aha, dann sieht der Autmoatisch genierierte quaise immer so aus:</p>
<pre><code class="language-cpp">Klasse::Klasse(const Klasse &amp;oQuelle){

this-&gt;V_1= oQuelle.V_1;
this-&gt;V_2= oQuelle.V_2;
this-&gt;V_3= oQuelle.V_3;
.
.
.
.
this-&gt;V_N= oQuelle.V_N;
</code></pre>
<p>}</p>
</blockquote>
<p>hm wie würde denn der copy ctor hierfür aussehen?</p>
<pre><code class="language-cpp">class Particle
{
public:
	//contructor
	Particle( SDL_Surface *img, Vektor *grav, Uint32 bgColor, int lifeTime = 0, double xpos = 0, double ypos = 0, double xvel = 0, double yvel = 0);

	const Particle&amp; operator=(const Particle &amp;right);
	void addFadeStruct(fadeStruct fs);
	void move(SDL_Surface *surf);
	SDL_Surface* getSprite();
	//dtor
	virtual ~Particle();

	//x,y, gravity, alive vals usw.
	Vektor position;
	Vektor velocity;
	Vektor *gravity;
	bool alive;
	Uint32 bgColor;
private:
	SDL_Surface *sprite;
	int spawntime;
	int lifetime;
	Uint32 replaceColor;
	bool hasFadeStruct;
	fadeStruct fade;
	Uint32 *sprPixels;

};
</code></pre>
<p>kann ich praktisch den operator= kopieren und den funktionskopf anpassen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321335</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:21:18 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:26:03 GMT]]></title><description><![CDATA[<p>@Boris: Praktisch ja - technisch läuft das eher auf Initialisierungslisten hinaus:</p>
<pre><code class="language-cpp">Klasse::Klasse(const Klasse&amp; src)
: Basis(src)
, V_1(src.V_1)
,
...
, V_N(src.V_N)
{}
</code></pre>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6059">@pixartist</a>: op= hat etwas andere Anforderungen als der CCtor (unter anderem braucht letzterer keinen Test auf Selbstzuweisung und muß die alten Objektdaten nicht freigeben).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321342</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:26:03 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:27:42 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>@Boris: Praktisch ja - technisch läuft das eher auf Initialisierungslisten hinaus:</p>
<pre><code class="language-cpp">Klasse::Klasse(const Klasse&amp; src)
: Basis(src)
, V_1(src.V_1)
,
...
, V_N(src.V_N)
{}
</code></pre>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6059">@pixartist</a>: op= hat etwas andere Anforderungen als der CCtor (unter anderem braucht letzterer keinen Test auf Selbstzuweisung und muß die alten Objektdaten nicht freigeben).</p>
</blockquote>
<p>hmm, wieso kann ich eigentlich beim operator= auf private's vom parameter zugreifen ? (und geht das auch beim copy ctor? )</p>
<p>was sind die anderen &quot;anderen anforderungen&quot; ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321345</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:27:42 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:31:11 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">class Particle 
{ 
public: 
    //contructor 
    Particle( SDL_Surface *img, Vektor *grav, Uint32 bgColor, int lifeTime = 0, double xpos = 0, double ypos = 0, double xvel = 0, double yvel = 0); 

    const Particle&amp; operator=(const Particle &amp;right); 
    void addFadeStruct(fadeStruct fs); 
    void move(SDL_Surface *surf); 
    SDL_Surface* getSprite(); 
    //dtor 
    virtual ~Particle(); 

    //x,y, gravity, alive vals usw. 
    Vektor position; //&lt;-- Tiefe Kopie
    Vektor velocity; //&lt;-- Tiefe Kopie
    Vektor *gravity;  // &lt;-- inhalt des Pointers für das neue Objekt mit new anlegen

    bool alive; //&lt;-- einfach zuweisung
    Uint32 bgColor; //&lt;-- einfach zuweisung
private: 
    SDL_Surface *sprite; // &lt;-- inhalt des Pointers für das neue Objekt mit new anlegen

    int spawntime; //&lt;-- einfach zuweisung
    int lifetime; //&lt;-- einfach zuweisung
    Uint32 replaceColor; //&lt;-- einfach zuweisung
    bool hasFadeStruct;   //&lt;-- einfach zuweisung
    fadeStruct fade; //&lt;-- einfach zuweisung (jenachdem was da drin ist)
    Uint32 *sprPixels; // &lt;-- inhalt des Pointers für das neue Objekt mit new anlegen

};
</code></pre>
<p>bei einem Poibnter komm es drauf an ob du für jede Instanz ein Objekt anlegen muss und dese npointer speicherst, oder ob du über den pointer ein externe Objekt referenzierst!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321349</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:31:11 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 10:32:11 GMT]]></title><description><![CDATA[<p>Erstens: private gilt auf Klassenebene, nicht auf Objektebene.</p>
<p>Zweitens: Der Copy-Ctor erzeugt eine Kopie aus dem Nichts, der op= ersetzt ein bestehendes Objekt - das sind schon ganz andere Arbeitsbedingungen. Das bedeutet auch, daß der Copy-Ctor keine Tests auf Selbstzuweisung durchführen muß (this ist immer ein jungfräuliches Objekt) und auch keine Alt-Daten entsorgen muß.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321352</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321352</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 09 Jul 2007 10:32:11 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:06:16 GMT]]></title><description><![CDATA[<p>Ich werde es wohl ausprobieren müssen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /><br />
Ausserdem ist der Grundansatz wohl eher ungeignet da sich auf die Art den Juds nur Kinder zugewiesen können bevor sie selbst in ein übergeordneten Hud gesteckt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321385</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321385</guid><dc:creator><![CDATA[GreyHound]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:06:16 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:14:03 GMT]]></title><description><![CDATA[<p>ähh was soll denn das jetzt ?</p>
<blockquote>
<p>__thiscall Particle::Particle(class Particle const &amp;)&quot; (??0Particle@@QAE@ABV0@@Z) bereits in Particle.obj definiert</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1321399</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321399</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:14:03 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:18:08 GMT]]></title><description><![CDATA[<p>Hast du vielleicht versucht, den Copy-Ctor direkt im Header zu definieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321404</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321404</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:18:08 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:19:45 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Hast du vielleicht versucht, den Copy-Ctor direkt im Header zu definieren?</p>
</blockquote>
<p>nö:</p>
<pre><code class="language-cpp">class Particle
{
public:
	//contructor
	Particle( SDL_Surface *img, Vektor *grav, Uint32 bgColor, int lifeTime = 0, double xpos = 0, double ypos = 0, double xvel = 0, double yvel = 0);
	//copy ctor
	Particle(const Particle &amp;right);

	const Particle&amp; operator=(const Particle &amp;right);
	void addFadeStruct(fadeStruct fs);
	void move(SDL_Surface *surf);
	//dtor
	virtual ~Particle();

	//x,y, gravity, alive vals
	Vektor position;
	Vektor velocity;
	Vektor *gravity;
	bool alive;
	Uint32 bgColor;
private:
	SDL_Surface *sprite;
	int spawntime;
	int lifetime;
	Uint32 replaceColor;
	bool hasFadeStruct;
	fadeStruct fade;
	Uint32 *sprPixels;

};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1321406</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321406</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:19:45 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:28:07 GMT]]></title><description><![CDATA[<p>Und wo stehen die dazugehörigen Methoden<strong>definitionen</strong>? (btw, bei welcher Datei beschwert sich eigentlich der Linker?)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321417</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321417</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:28:07 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:53:09 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Und wo stehen die dazugehörigen Methoden<strong>definitionen</strong>? (btw, bei welcher Datei beschwert sich eigentlich der Linker?)</p>
</blockquote>
<p>in der Particle.ccp <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">#include &quot;Particle.h&quot;

//contructor
Particle::Particle(SDL_Surface *img, Vektor *grav, Uint32 bgColor, int lifeTime, double xpos, double ypos, double xvel, double yvel)
{
	gravity = grav;
	sprite = img;
	position.x = xpos;
	position.y = ypos;
	velocity.x = xvel;
	velocity.y = yvel;
	alive = true;
	spawntime = SDL_GetTicks();
	lifetime = lifeTime;
	replaceColor = bgColor;
	hasFadeStruct = false;
	sprPixels = (Uint32 *)sprite-&gt;pixels;
}
Particle::Particle(const Particle &amp;p)
{
	gravity = p.gravity;
	sprite = p.sprite;
	sprite-&gt;refcount++;

	position = p.position;
	velocity = p.velocity;
	alive = true;
	spawntime = SDL_GetTicks();
	lifetime = p.lifetime;
	replaceColor = p.replaceColor;
	hasFadeStruct = p.hasFadeStruct;
	sprPixels = (Uint32 *)sprite-&gt;pixels;
	if(hasFadeStruct)
		fade = p.fade;
}

const Particle&amp; Particle::operator=(const Particle &amp;right)
{
	if(this != &amp;right)
	{
		gravity = right.gravity;
		gravity = right.gravity;
		sprite = right.sprite;
		sprite-&gt;refcount++;
		position = right.position;
		velocity = right.velocity;
		alive = true;
		spawntime = SDL_GetTicks();
		lifetime = right.lifetime;
		replaceColor = right.replaceColor;
		hasFadeStruct = right.hasFadeStruct;
		sprPixels = (Uint32 *)sprite-&gt;pixels;
		fade = right.fade;
	}
	return *this;
}
....
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1321444</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321444</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 11:58:02 GMT]]></title><description><![CDATA[<p>pixartist schrieb:</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>Und wo stehen die dazugehörigen Methoden<strong>definitionen</strong>? (btw, bei welcher Datei beschwert sich eigentlich der Linker?)</p>
</blockquote>
<p>in der Particle.ccp <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p><em>Und bei welcher Datei beschwert sich der Linker?</em></p>
<p>Bindest du irgendwelche .cpp-Dateien mittels Includedirektive in andere ein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321452</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 09 Jul 2007 11:58:02 GMT</pubDate></item><item><title><![CDATA[Reply to warum stürzt das ab(push_back bei vector) on Mon, 09 Jul 2007 12:16:29 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>pixartist schrieb:</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>Und wo stehen die dazugehörigen Methoden<strong>definitionen</strong>? (btw, bei welcher Datei beschwert sich eigentlich der Linker?)</p>
</blockquote>
<p>in der Particle.ccp <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
</blockquote>
<p><em>Und bei welcher Datei beschwert sich der Linker?</em></p>
<p>Bindest du irgendwelche .cpp-Dateien mittels Includedirektive in andere ein?</p>
</blockquote>
<p>achso ja:</p>
<pre><code class="language-cpp">PSpawner.obj : error LNK2005: &quot;public: __thiscall Particle::P...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1321468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321468</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 09 Jul 2007 12:16:29 GMT</pubDate></item></channel></rss>