<?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[std:: bad alloc]]></title><description><![CDATA[<p>Hi zusammen!</p>
<p>Also eine weitere Frage:</p>
<p>beim Aufruf der Methode:.</p>
<pre><code class="language-cpp">Node&amp; NodePool::createNode(GNG_Parameters&amp; gng_parameters, NodePool&amp; nodepool)
{

	Node newNode = Node(gng_parameters, nodepool); // Konstruktor
	int actualNodeId_int = *newNode.getNodeId();   // vergibt Node eine ID
	nodelist_list.push_back(newNode);              // fügt Node is Liste ein
	existingNodes[actualNodeId_int] = true;        // setzt Node auf existing

	return newNode;

}
</code></pre>
<p>Wir ein Node Objekt erstellt. Daraufhin wird eine Referenz auf das Node Objekt zurückgegeben.</p>
<p>Aufgerufen wird diese Methode von einer anderen Klasse:</p>
<pre><code class="language-cpp">Node firstNode = nodepool.createNode(gng_parameters,nodepool);
</code></pre>
<p>Wieso erhalte ich immer<br />
<em>std::bad_alloc'<br />
what(): std::bad_alloc</em><br />
Ich dachte das bekomme ich wenn ich dynamische Objekte erstelle und da etwas schief geht.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/224876/std-bad-alloc</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 03:29:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/224876.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Oct 2008 08:05:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std:: bad alloc on Thu, 16 Oct 2008 08:05:28 GMT]]></title><description><![CDATA[<p>Hi zusammen!</p>
<p>Also eine weitere Frage:</p>
<p>beim Aufruf der Methode:.</p>
<pre><code class="language-cpp">Node&amp; NodePool::createNode(GNG_Parameters&amp; gng_parameters, NodePool&amp; nodepool)
{

	Node newNode = Node(gng_parameters, nodepool); // Konstruktor
	int actualNodeId_int = *newNode.getNodeId();   // vergibt Node eine ID
	nodelist_list.push_back(newNode);              // fügt Node is Liste ein
	existingNodes[actualNodeId_int] = true;        // setzt Node auf existing

	return newNode;

}
</code></pre>
<p>Wir ein Node Objekt erstellt. Daraufhin wird eine Referenz auf das Node Objekt zurückgegeben.</p>
<p>Aufgerufen wird diese Methode von einer anderen Klasse:</p>
<pre><code class="language-cpp">Node firstNode = nodepool.createNode(gng_parameters,nodepool);
</code></pre>
<p>Wieso erhalte ich immer<br />
<em>std::bad_alloc'<br />
what(): std::bad_alloc</em><br />
Ich dachte das bekomme ich wenn ich dynamische Objekte erstelle und da etwas schief geht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1599758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1599758</guid><dc:creator><![CDATA[redbomber]]></dc:creator><pubDate>Thu, 16 Oct 2008 08:05:28 GMT</pubDate></item><item><title><![CDATA[Reply to std:: bad alloc on Thu, 16 Oct 2008 08:20:24 GMT]]></title><description><![CDATA[<p>Na, irgendwo wirst du wohl ein new drin haben. Was ist denn mit <code>nodelist_list.push_back(newNode);</code> ? Da wird im push_back bestimmt ein new gemacht, wenn nötig. Hast du keinen vernünftigen Debugger?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1599767</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1599767</guid><dc:creator><![CDATA[Bulli]]></dc:creator><pubDate>Thu, 16 Oct 2008 08:20:24 GMT</pubDate></item><item><title><![CDATA[Reply to std:: bad alloc on Thu, 16 Oct 2008 08:23:49 GMT]]></title><description><![CDATA[<p>Also ich habe dies jetzt wie folgt gelöst/umgangen</p>
<p>ich rufe die Methode createNode wie folgt auf:</p>
<pre><code class="language-cpp">Node firstNode;
nodepool.createNode(gng_parameters,nodepool,firstNode);
</code></pre>
<p>Also erstelle zuerst einen default Node und übergebe daraufhin eine Referenz dieses Nodes an die Methode createNode.</p>
<pre><code class="language-cpp">Node&amp; NodePool::createNode(GNG_Parameters&amp; gng_parameters, NodePool&amp; nodepool, Node&amp; actualNode)
{

	actualNode = Node(gng_parameters, nodepool);
	int actualNodeId_int = *actualNode.getNodeId();
	nodelist_list.push_back(actualNode);
	existingNodes[actualNodeId_int] = true;

	return actualNode;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1599768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1599768</guid><dc:creator><![CDATA[redbomber]]></dc:creator><pubDate>Thu, 16 Oct 2008 08:23:49 GMT</pubDate></item><item><title><![CDATA[Reply to std:: bad alloc on Thu, 16 Oct 2008 08:25:18 GMT]]></title><description><![CDATA[<p>Nein, ein new habe ich nirgendwo drinnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1599770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1599770</guid><dc:creator><![CDATA[redbomber]]></dc:creator><pubDate>Thu, 16 Oct 2008 08:25:18 GMT</pubDate></item><item><title><![CDATA[Reply to std:: bad alloc on Thu, 16 Oct 2008 09:00:34 GMT]]></title><description><![CDATA[<p>Du gibst eine Referenz auf ein lokales Objekt zurück. Das alleine ist schon nicht erlaubt. (auf das dich der Compiler auch hinweist!).<br />
Das Objekt wird am Ende der Funktion auch bereits wieder zerstört und somit ist die Referenz ungültig. Und alles, was du nachher damit machst ist undefiniert.</p>
<p>btw:<br />
Kommt es dir selber nicht komisch vor, dass du eine create Funktion hast, aber nirgends Speicher anforderst?! - Das alleine sollte dich schon stutzig machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1599788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1599788</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Thu, 16 Oct 2008 09:00:34 GMT</pubDate></item></channel></rss>