<?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[Statische Objecte]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versuche mir gerade eine Klasse zu schreiben, die Funktionen die ich oft nutze enthält.<br />
Z.B. eine Funtion StrToFloat().<br />
Das Problem ist, die Funktion soll statisch sein.<br />
Allerdings braucht sie einen Stringstream.<br />
Jedes mal einen in der Funktion erstellen ist wohl blöd, daher will ich ihn lieber als private static haben, sodass ich mehrmals auf ihn zugreifen kann.<br />
Nur - wie initialisiere ich ihn dann?</p>
<pre><code class="language-cpp">private:
	static std::stringstream strStream;
</code></pre>
<p>Klappt halt leider nicht. (Kompiler Error - &quot;nicht aufgelöstes externes Symbol...&quot;)</p>
<p>Wie würdet ihr das angehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/282705/statische-objecte</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 00:34:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/282705.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Feb 2011 18:09:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Statische Objecte on Thu, 24 Feb 2011 18:09:12 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich versuche mir gerade eine Klasse zu schreiben, die Funktionen die ich oft nutze enthält.<br />
Z.B. eine Funtion StrToFloat().<br />
Das Problem ist, die Funktion soll statisch sein.<br />
Allerdings braucht sie einen Stringstream.<br />
Jedes mal einen in der Funktion erstellen ist wohl blöd, daher will ich ihn lieber als private static haben, sodass ich mehrmals auf ihn zugreifen kann.<br />
Nur - wie initialisiere ich ihn dann?</p>
<pre><code class="language-cpp">private:
	static std::stringstream strStream;
</code></pre>
<p>Klappt halt leider nicht. (Kompiler Error - &quot;nicht aufgelöstes externes Symbol...&quot;)</p>
<p>Wie würdet ihr das angehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026032</guid><dc:creator><![CDATA[Mathews]]></dc:creator><pubDate>Thu, 24 Feb 2011 18:09:12 GMT</pubDate></item><item><title><![CDATA[Reply to Statische Objecte on Thu, 24 Feb 2011 18:12:25 GMT]]></title><description><![CDATA[<p>In die .cpp-Datei der Implementierung muss zusätzlich noch:</p>
<pre><code class="language-cpp">std::stringstream MeineKlasse::strStream;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2026033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026033</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 24 Feb 2011 18:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to Statische Objecte on Thu, 24 Feb 2011 18:28:21 GMT]]></title><description><![CDATA[<p>Es klappt so - aber für was braucht es denn das?<br />
Also das man das zweimal deklarieren muss?<br />
Steckt da irgend ein tieferer Sinn dahinter? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026041</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026041</guid><dc:creator><![CDATA[Mathews]]></dc:creator><pubDate>Thu, 24 Feb 2011 18:28:21 GMT</pubDate></item><item><title><![CDATA[Reply to Statische Objecte on Thu, 24 Feb 2011 18:32:54 GMT]]></title><description><![CDATA[<p>In der CPP Datei ist die Implementation. Der Header ist nur die Schnittstelle.<br />
bei dem Beispiel von Decimad wird einfach nur der Standardkonstruktor aufgerufen. Alterantiv, kannst du ja auch einen anderen Konstruktor aufrufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026043</guid><dc:creator><![CDATA[xXxTrollxXx]]></dc:creator><pubDate>Thu, 24 Feb 2011 18:32:54 GMT</pubDate></item><item><title><![CDATA[Reply to Statische Objecte on Thu, 24 Feb 2011 18:34:14 GMT]]></title><description><![CDATA[<p>Naja, statischen Datenmembern ist ja kein Speicherplatz &quot;innerhalb&quot; von deren Objekten zugeordnet, aber irgendwo muss ihre eindeutige Instanz ja erstellt werden, auf die sich dann alle Übersetzungseinheiten beziehen können. Ist halt wie mit globalen Variablen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026044</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 24 Feb 2011 18:34:14 GMT</pubDate></item><item><title><![CDATA[Reply to Statische Objecte on Thu, 24 Feb 2011 19:08:53 GMT]]></title><description><![CDATA[<p>Oki, vielen dank für die erläuterung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2026060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2026060</guid><dc:creator><![CDATA[Mathews]]></dc:creator><pubDate>Thu, 24 Feb 2011 19:08:53 GMT</pubDate></item></channel></rss>