<?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[Verkettete Listen in Funktionen]]></title><description><![CDATA[<p>hallo,<br />
ich habe folgendes Problem. Ich möchte eine Liste mit mehreren Behältern nach einander auffüllen. Das klappt auch ganz gut solange man es einzelnd im Hauptprogramm macht. Möchte ich diese Aufgabe jedoch in eine Funktion einbaun wird ständig der letzte Wert überschrieben.</p>
<pre><code>int c = 5,d = 6, e = 7;
	node *p, *q, *erster, *r;
	erster = new node;
	p=erster;
	p-&gt;data = 1;
	p-&gt;next = NULL;

	q = new node;
	q-&gt;data = 2;
	q-&gt;next = NULL;

	p-&gt;next = q;
	p = q;
	p-&gt;next = NULL;
</code></pre>
<p>so funktionierts immer. Ich kann den Teil nach q = new node bis einschließlich p-&gt;next = NULL beliebig oft kopieren und es wird immer ein Behälter angehangen.</p>
<p>baue ich das ganze jedoch in eine Funktion ein funktioniert es nicht mehr!</p>
<p>Funktion sieht so aus.</p>
<pre><code>int push(node *p, node* q,int nr) {
	q = new node;
	q-&gt;data = nr;
	q-&gt;next = NULL;

	p-&gt;next = q;
	p = q;
	p-&gt;next = NULL;
	return 0;
}
</code></pre>
<p>und ich kann den Fehler einfach nicht finden</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/326594/verkettete-listen-in-funktionen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 26 May 2026 19:17:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/326594.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jun 2014 14:52:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 14:52:12 GMT]]></title><description><![CDATA[<p>hallo,<br />
ich habe folgendes Problem. Ich möchte eine Liste mit mehreren Behältern nach einander auffüllen. Das klappt auch ganz gut solange man es einzelnd im Hauptprogramm macht. Möchte ich diese Aufgabe jedoch in eine Funktion einbaun wird ständig der letzte Wert überschrieben.</p>
<pre><code>int c = 5,d = 6, e = 7;
	node *p, *q, *erster, *r;
	erster = new node;
	p=erster;
	p-&gt;data = 1;
	p-&gt;next = NULL;

	q = new node;
	q-&gt;data = 2;
	q-&gt;next = NULL;

	p-&gt;next = q;
	p = q;
	p-&gt;next = NULL;
</code></pre>
<p>so funktionierts immer. Ich kann den Teil nach q = new node bis einschließlich p-&gt;next = NULL beliebig oft kopieren und es wird immer ein Behälter angehangen.</p>
<p>baue ich das ganze jedoch in eine Funktion ein funktioniert es nicht mehr!</p>
<p>Funktion sieht so aus.</p>
<pre><code>int push(node *p, node* q,int nr) {
	q = new node;
	q-&gt;data = nr;
	q-&gt;next = NULL;

	p-&gt;next = q;
	p = q;
	p-&gt;next = NULL;
	return 0;
}
</code></pre>
<p>und ich kann den Fehler einfach nicht finden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405563</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 14:52:12 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 15:09:56 GMT]]></title><description><![CDATA[<p>Funktioniert nicht, aha.</p>
<p>Du suchst vermutlich call by reference.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405566</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 25 Jun 2014 15:09:56 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 15:11:52 GMT]]></title><description><![CDATA[<p>Sag mal, wie du die Funktion dann aufrufst.</p>
<p>Das sieht verdächtig aus, dass du ein node* q übergibst, dass aber sofort überschreibst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405567</guid><dc:creator><![CDATA[Elton John Wayne Rooney]]></dc:creator><pubDate>Wed, 25 Jun 2014 15:11:52 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 15:12:25 GMT]]></title><description><![CDATA[<p>hatten wir in meinem kurs noch nicht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405568</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 15:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 15:17:36 GMT]]></title><description><![CDATA[<p>ich rufe die Funktion mit</p>
<pre><code>push(p,q,c);
</code></pre>
<p>auf.</p>
<p>c ist weiter oben im Programm definiert und initialisiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405570</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405570</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 15:17:36 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 16:54:39 GMT]]></title><description><![CDATA[<p>hallo ich habe noch ein weiteres Problem!</p>
<pre><code>int pop(node *anker, node *a) {
	cout &lt;&lt; &quot;Waggon-Nr.: &quot; &lt;&lt; anker-&gt;nummer &lt;&lt; &quot; entnommen.&quot; &lt;&lt; endl;
	a=anker;
	anker=anker-&gt;next;
	delete (a);
	return 1;
</code></pre>
<p>diese Funktion löscht den Listenkopf und ernennt automatisch den nächsten Teil zum neuen Listenkopf, aber ich kann diese Funktion nur einmal in meinem Programm benutzen, sollte ich es nochmal benutzen stürzt das Programm ab! Woran könnte das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405576</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 16:54:39 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 17:44:07 GMT]]></title><description><![CDATA[<p>Hallo, beide Fragen wurden schon beantwortet. <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>
<p>manni66 schrieb:</p>
<blockquote>
<p>Funktioniert nicht, aha.</p>
<p>Du suchst vermutlich call by reference.</p>
</blockquote>
<pre><code>void push(node *&amp;p /*, node* q*/,int nr) {
    p=p-&gt;next = new node;
    p-&gt;data=nr;
    p-&gt;next = NULL;
}
</code></pre>
<p>Und was '&amp;' mit manni66` Antwort zu tun hat und was du bei pop änderst, findest du sicherlich alleine raus...<br />
MFG John.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405578</guid><dc:creator><![CDATA[John1]]></dc:creator><pubDate>Wed, 25 Jun 2014 17:44:07 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 17:51:38 GMT]]></title><description><![CDATA[<p>eigentlich möchte mein Dozent das ja nicht in dieser Form haben aber weil ich eh schon einen Tag in Verzug bin versuch ich mir mal die Parameterüber über call by reference anzueignen. Muss er das halt so akzeptieren. Dankeschön</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405584</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 17:51:38 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 17:55:44 GMT]]></title><description><![CDATA[<p>Vermutlich unterrichtet dein Dozent eher C und will das so haben:</p>
<pre><code>void push(node **p /*, node* q*/,int nr) {
    *p=p-&gt;next = new node;
    (*p)-&gt;data=nr;
    (*p)-&gt;next = NULL;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2405585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405585</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 25 Jun 2014 17:55:44 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 18:24:44 GMT]]></title><description><![CDATA[<p>das &amp; steht ja für den address-of-operator so weit ich weiß. Wie erfolgt denn hier der Aufruf der Funktion in der mainfunktion?<br />
ich bekomme da folgende Fehlermeldung: Mehrere Funktionen von &quot;Überladene Funktion&quot;push&quot;&quot; stimmen mit der Argumentliste überein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405589</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 18:24:44 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 18:26:41 GMT]]></title><description><![CDATA[<p>genau das doppelte Sternchen hat er einmal in seiner Vorlesung erwähnt wird jedoch nicht in seinem Script genauer bearbeitet. jetzt fällts mir wieder ein ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405590</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 18:26:41 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 18:40:37 GMT]]></title><description><![CDATA[<p>Diandranewby schrieb:</p>
<blockquote>
<p>das &amp; steht ja für den address-of-operator so weit ich weiß. Wie erfolgt denn hier der Aufruf der Funktion in der mainfunktion?<br />
ich bekomme da folgende Fehlermeldung: Mehrere Funktionen von &quot;Überladene Funktion&quot;push&quot;&quot; stimmen mit der Argumentliste überein.</p>
</blockquote>
<p>Das ist eine sog. Referenz.<br />
Das ist quasi wie ein doppelter Pointer, nur kannst du es ohne &amp;val aufrufen und den Wert ohne *ptr lesen/schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405591</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 25 Jun 2014 18:40:37 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 18:45:53 GMT]]></title><description><![CDATA[<p>jetzt hab ich ein Problem mit dem linker der Compiler gibt gleich zwei Fehlermeldungen an. LNK1120: Nicht aufgelöste externe Verweise und LNK 2019: Verweis auf nicht aufgelöstes externes Symbol.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405592</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 18:45:53 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 18:46:39 GMT]]></title><description><![CDATA[<p>Die Definition passt nicht zur Deklaration, zeig mal Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405593</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405593</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 25 Jun 2014 18:46:39 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 18:53:44 GMT]]></title><description><![CDATA[<pre><code>int pop(waggon **anker,waggon **p) {
	if(isEmpty(anker)) return 0;

	*p=*anker;
	*anker=(*anker)-&gt;next;
	delete (p);
	return 1;
}
</code></pre>
<pre><code>int pop(waggon **);
</code></pre>
<p>ein kleiner Auszug</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405596</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 18:53:44 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 19:06:50 GMT]]></title><description><![CDATA[<p>Ja, die Deklaration hat einen Parameter, die Definition zwei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405599</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 25 Jun 2014 19:06:50 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 19:07:28 GMT]]></title><description><![CDATA[<pre><code>int erzeugestack(waggon **anker,waggon**p,uint nr)
{
	*anker = new waggon;
	*p=*anker;
	(*p)-&gt;nummer = nr;
	(*p)-&gt;next = NULL;
	return 0;
}
</code></pre>
<p>da wird auch ein fehler angezeigt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405600</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 19:07:28 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 19:10:25 GMT]]></title><description><![CDATA[<p>ok das hätte mir auch auffallen können ^^</p>
<pre><code>int erzeugestack(waggon **,waggon**,uint);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2405602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405602</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 19:10:25 GMT</pubDate></item><item><title><![CDATA[Reply to Verkettete Listen in Funktionen on Wed, 25 Jun 2014 19:18:24 GMT]]></title><description><![CDATA[<p>ich kann das Programm jetzt jedenfalls starten aber es bricht sehr schnell wieder ab und zwar wenn die Funktion die in dem post über diesem hier gepostet wurde aufgerufen wird.</p>
<p>&quot;Unbehandelte Ausnahme 0x00a1087 in Kriteriumsaufgabe.exe<br />
.Zugriffsverletzung beim Schreiben an Position 0x0000000&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405606</guid><dc:creator><![CDATA[Diandranewby]]></dc:creator><pubDate>Wed, 25 Jun 2014 19:18:24 GMT</pubDate></item></channel></rss>