<?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[OOP]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich hoffe mir kann wer weiterhelfen, ich bin ratlos:</p>
<p>Habe beschlossen mich mit Klassen herrumzuschlagen, soweit so gut, auch ein test Prog geschrieben, ABER wenn ich auf das kleine Wort static verzichte Funktioniert gar nichts mehr, die frage ist warum?</p>
<p>Hier mein code:</p>
<p>main.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;iostream&quot;
#include &quot;testklasse.h&quot;

using namespace std;

int x = 1;
int y = 2;

int _tmain(int argc, _TCHAR* argv[])
{
	cout&lt;&lt; &quot;main&quot;;

	int ergebnis = test.mytest(x,y);
	test.ausgabe(ergebnis);

	cin.get();
	return 0;
}
</code></pre>
<p>testklasse.cpp</p>
<pre><code>#include &quot;testklasse.h&quot;
#include &quot;iostream&quot;

using namespace std;

int testklasse::mytest(int x,int y)
{
	int erg = x+y;
	return erg;
}

void testklasse::ausgabe(int x)
{
	cout&lt;&lt; &quot;das ergebnis ist: \n&quot; &lt;&lt; x;
}
</code></pre>
<p>testklasse.h</p>
<pre><code>#ifndef TESTKLASSE_H
#define TESTKLASSE_H
[b]static class testklasse[/b]
{
public:
	int mytest(int , int);
	void ausgabe(int);
}test;

#endif /*TESTKLASSE_H*/
</code></pre>
<p>Warum muss es eine <strong>static</strong> class sein?<br />
Bzw, wie kann man die vermeiden?</p>
<p>Bin für alle arten von vorschlägen offen.</p>
<p>Mfg lattella</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/307696/oop</link><generator>RSS for Node</generator><lastBuildDate>Thu, 06 Aug 2026 15:50:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/307696.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 02 Sep 2012 18:32:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OOP on Sun, 02 Sep 2012 18:32:17 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich hoffe mir kann wer weiterhelfen, ich bin ratlos:</p>
<p>Habe beschlossen mich mit Klassen herrumzuschlagen, soweit so gut, auch ein test Prog geschrieben, ABER wenn ich auf das kleine Wort static verzichte Funktioniert gar nichts mehr, die frage ist warum?</p>
<p>Hier mein code:</p>
<p>main.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;iostream&quot;
#include &quot;testklasse.h&quot;

using namespace std;

int x = 1;
int y = 2;

int _tmain(int argc, _TCHAR* argv[])
{
	cout&lt;&lt; &quot;main&quot;;

	int ergebnis = test.mytest(x,y);
	test.ausgabe(ergebnis);

	cin.get();
	return 0;
}
</code></pre>
<p>testklasse.cpp</p>
<pre><code>#include &quot;testklasse.h&quot;
#include &quot;iostream&quot;

using namespace std;

int testklasse::mytest(int x,int y)
{
	int erg = x+y;
	return erg;
}

void testklasse::ausgabe(int x)
{
	cout&lt;&lt; &quot;das ergebnis ist: \n&quot; &lt;&lt; x;
}
</code></pre>
<p>testklasse.h</p>
<pre><code>#ifndef TESTKLASSE_H
#define TESTKLASSE_H
[b]static class testklasse[/b]
{
public:
	int mytest(int , int);
	void ausgabe(int);
}test;

#endif /*TESTKLASSE_H*/
</code></pre>
<p>Warum muss es eine <strong>static</strong> class sein?<br />
Bzw, wie kann man die vermeiden?</p>
<p>Bin für alle arten von vorschlägen offen.</p>
<p>Mfg lattella</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2247919</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2247919</guid><dc:creator><![CDATA[lattella]]></dc:creator><pubDate>Sun, 02 Sep 2012 18:32:17 GMT</pubDate></item><item><title><![CDATA[Reply to OOP on Sun, 02 Sep 2012 18:35:48 GMT]]></title><description><![CDATA[<p>Das <code>static</code> bezieht sich auf das <code>test</code> -Objekt. Verwende einfach keine globalen Objekte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2247922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2247922</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Sun, 02 Sep 2012 18:35:48 GMT</pubDate></item><item><title><![CDATA[Reply to OOP on Sun, 02 Sep 2012 18:53:41 GMT]]></title><description><![CDATA[<p>Erst mal danke für die schnelle antwort,</p>
<p>verstehe allerdings nicht genau was du meinst, soll ich auf das test objekt verzichten?</p>
<p>lg lattella</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2247929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2247929</guid><dc:creator><![CDATA[lattella]]></dc:creator><pubDate>Sun, 02 Sep 2012 18:53:41 GMT</pubDate></item><item><title><![CDATA[Reply to OOP on Sun, 02 Sep 2012 18:58:13 GMT]]></title><description><![CDATA[<blockquote>
<p>verstehe allerdings nicht genau was du meinst, soll ich auf das test objekt verzichten?</p>
</blockquote>
<p>Nicht verzichten, sondern anders einsetzen. Das globale Objekt test wird nicht mehr benötigt, dafür sollst Du so lokal wie möglich ein solches Objekt erzeugen.</p>
<pre><code class="language-cpp">int _tmain(int argc, _TCHAR* argv[])
{
    cout&lt;&lt; &quot;main&quot;;

    testklasse test;
    int ergebnis = test.mytest(x,y);
    test.ausgabe(ergebnis);

    cin.get();
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2247932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2247932</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Sun, 02 Sep 2012 18:58:13 GMT</pubDate></item><item><title><![CDATA[Reply to OOP on Sun, 02 Sep 2012 19:08:34 GMT]]></title><description><![CDATA[<p>Ahhh okay, danke, dachte dass das in diesem simplen prog keinen unterschied macht.</p>
<p>Vielen dank für eure schnellen antworten, hätte nie gedacht dass es im deutschsprachigen raum ein so aktives forum gibt, werde euch auch in zukunft mit meinen fragen belästigen <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>Thx vm</p>
<p>lattella</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2247936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2247936</guid><dc:creator><![CDATA[lattella]]></dc:creator><pubDate>Sun, 02 Sep 2012 19:08:34 GMT</pubDate></item></channel></rss>