<?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[Ähm, schaut mal]]></title><description><![CDATA[<p>hi, gibt es eine möglichkeit dass mir eine funktion eine variable erschafft, welche nach der funktion noch verfügbar ist?</p>
<p>in der art</p>
<p>void foo()<br />
{<br />
int i = 15<br />
}</p>
<p>und nach der funktion ist i noch verfügbar?</p>
<p>was ich NICHT benötige ist ein rückgabewert, auch keine manipulation über referenz oder zeiger von existenten variablen, noch soll i bereits deklariert sein,</p>
<p>die funktion soll mir i ERSTELLEN,</p>
<p>ich glaube zwar nicht dass das so einfach geht aber möglichkeiten werden gern gesehn^^</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/224387/ähm-schaut-mal</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 18:26:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/224387.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Oct 2008 21:57:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 21:57:48 GMT]]></title><description><![CDATA[<p>hi, gibt es eine möglichkeit dass mir eine funktion eine variable erschafft, welche nach der funktion noch verfügbar ist?</p>
<p>in der art</p>
<p>void foo()<br />
{<br />
int i = 15<br />
}</p>
<p>und nach der funktion ist i noch verfügbar?</p>
<p>was ich NICHT benötige ist ein rückgabewert, auch keine manipulation über referenz oder zeiger von existenten variablen, noch soll i bereits deklariert sein,</p>
<p>die funktion soll mir i ERSTELLEN,</p>
<p>ich glaube zwar nicht dass das so einfach geht aber möglichkeiten werden gern gesehn^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595914</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595914</guid><dc:creator><![CDATA[gasst]]></dc:creator><pubDate>Wed, 08 Oct 2008 21:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 22:03:15 GMT]]></title><description><![CDATA[<p>So:</p>
<pre><code class="language-cpp">void foo()
{
public:
int i = 15
}
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/1595915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595915</guid><dc:creator><![CDATA[Veratex]]></dc:creator><pubDate>Wed, 08 Oct 2008 22:03:15 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 22:09:03 GMT]]></title><description><![CDATA[<p>ok, wenn ich folgendes in code::blocks eingebe:</p>
<pre><code>#include &lt;iostream&gt;

using namespace std;

void foo()
{
    public:
    int i = 12;
}
int main()
{
    int i;
    i = 15;
    cout &lt;&lt; &quot;vor foo: &quot; &lt;&lt; i &lt;&lt; endl;
    foo();
    cout &lt;&lt; &quot;nach foo: &quot; &lt;&lt; i &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>gibts folgendes:</p>
<blockquote>
<p>C:\Programme\CodeBlocks\MEINS\test\main.cpp||In function <code>void foo()':| C:\\Programme\\CodeBlocks\\MEINS\\test\\main.cpp|7|error: expected primary-expression before &quot;public&quot;| C:\\Programme\\CodeBlocks\\MEINS\\test\\main.cpp|7|error: expected</code>;' before &quot;public&quot;|<br />
||=== Build finished: 2 errors, 0 warnings ===|</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1595918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595918</guid><dc:creator><![CDATA[gasst]]></dc:creator><pubDate>Wed, 08 Oct 2008 22:09:03 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 22:46:26 GMT]]></title><description><![CDATA[<p>Das wird nicht funktionieren. Du könntest das aber mit einem this-Zeiger lösen. Hier ein Link: <a href="http://tutorial.schornboeck.net/this.htm" rel="nofollow">http://tutorial.schornboeck.net/this.htm</a> . <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595931</guid><dc:creator><![CDATA[Veratex]]></dc:creator><pubDate>Wed, 08 Oct 2008 22:46:26 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 22:50:47 GMT]]></title><description><![CDATA[<p>Es geht nicht. Die Variable ist nur innerhalb der Funktion sichtbar. Das hinter der Variable liegende Objekt (das u.U. auch außerhalb der Funktion noch existiert) scheint dich ja nicht zu interessieren, sondern wirklich die Variable an sich.</p>
<p>Ist das eine reine Neugierfrage oder hast du irgendwas bestimmtes vor?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595935</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 08 Oct 2008 22:50:47 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 23:03:41 GMT]]></title><description><![CDATA[<p>nunja, was bestimmtes eig schon:</p>
<p>ich möchte mir funktionen schaffen die mir das erstellen von fenstern und allen möglichen objekten erleichtern</p>
<p>zB in einem spiel möchte ich statt Window x(auflösung, name, stil,...)<br />
nur noch CreateWindow() aufrufen können, natürlich muss das fenster danach noch existieren ...<br />
dachte schon darüber nach eine klasse spiel zu schreiben in dem ein Window bestandteil ist, allerdings müsste ich das dann eig protected deklarieren und dann eine funktion Window&amp; GetWindow() oder so schreiben, und spätere aufrufe wie spiel.getwindow().resize() sind halt net besonders gut zu lesen denk ich, da wär es mir recht eine funktion erzeugt mir des ;</p>
<p>hmm welche &quot;professionellen&quot; alternativen hab ich denn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595938</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595938</guid><dc:creator><![CDATA[gassst]]></dc:creator><pubDate>Wed, 08 Oct 2008 23:03:41 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 23:16:06 GMT]]></title><description><![CDATA[<p>Naja ganz grundsätzlich als Rückgabewert einer Funktion</p>
<pre><code class="language-cpp">Window createWindow() {
  Window w = ...
  bla

  return w;
}

int main() {
  Window w = createWindow();
  w.resize(blub);
}
</code></pre>
<p>Nur mal die Grundidee ... Windows werden wohl meistens als Zeiger rumgereicht. Es geht hier nur darum, dass du ja eigentlich nicht die Variable erzeugen willst, sondern ein Objekt. Wenn man das ganze noch weiter treibt stößt man irgendwann auf das Factory Pattern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595939</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 08 Oct 2008 23:16:06 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 23:20:19 GMT]]></title><description><![CDATA[<blockquote>
<p>Window w = createWindow();</p>
</blockquote>
<p>eben solch eine zeile wollt ich mir sparen; aber ich denke dass ich wohl nicht drum herum komme <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title="=)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595940</guid><dc:creator><![CDATA[gasst]]></dc:creator><pubDate>Wed, 08 Oct 2008 23:20:19 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Wed, 08 Oct 2008 23:28:44 GMT]]></title><description><![CDATA[<p>Was ist an der Zeile schlimmer als an <code>createWindow();</code> ? (Außer 10 Zeichen zusätzlich...)</p>
<p>Naja also wenns unbedingt sein muss kannst du Variablen mit einem Makro erzeugen. Bei deinem Allerwelts-Anwendungsfall würde ich das aber nicht machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595942</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 08 Oct 2008 23:28:44 GMT</pubDate></item><item><title><![CDATA[Reply to Ähm, schaut mal on Thu, 09 Oct 2008 01:32:21 GMT]]></title><description><![CDATA[<p>Du kannst dir eine eigene kleine Mini-Engine bzw. ein Mini-Framework basteln, welches &quot;benannte Objekte&quot; verwalten kann.<br />
Dann hättest du z.B. eine &quot;Game&quot; Klasse, die ein Container von Objekten (u.U. verschiedenen Typs) ist.<br />
Die &quot;Game&quot; Klasse kann dann ohne Weiteres eine Funktion &quot;CreateWindow&quot; haben, die ein Fenster als &quot;benanntes Objekt&quot; erstellt. Die &quot;benannten Objekte&quot; speichert die &quot;Game&quot; Klasse dann z.B. in einer map/unordered_map. Zugriff auf die Objekte kannste du dann via Lookup-Funktionen (&quot;GetWindow&quot; oder einfach &quot;GetObject&quot;) machen.<br />
Ob das dann angenehmer zu Programmieren ist ist natürlich die Frage.</p>
<p>Natürlich gibt es auch fertige Engines die ähnliche Funktionen implementieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1595959</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1595959</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 09 Oct 2008 01:32:21 GMT</pubDate></item></channel></rss>