<?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[[MVSC++6.0] Problem bei Deklaration und Definition von Methoden]]></title><description><![CDATA[<p>Moinsen Community !</p>
<p>Ich bin grade dabei mir selbst C++ beizubringen.<br />
So. Nun iss ja alles gut und schön, hab ich folgendes Problem:<br />
Beim versuch in der menue.cpp die Methode zu Definieren wirft der Compiler<br />
[MSVC++6.0] folgende Fehlermeldung aus:</p>
<blockquote>
<p>J:\Eigene Dateien\Meine Projekte\noname002\main.cpp(29) : error C2352: 'C_Menue::DrawMenue' : Unzulaessiger Aufruf einer nichtstatischen Member-Funktion<br />
j:\eigene dateien\meine projekte\noname002\menue.h(6) : Siehe Deklaration von 'DrawMenue'</p>
</blockquote>
<p>Warum muss ich eine statische Methode Deklarieren, damit ich sie später<br />
Definieren kann ?<br />
Soweit ich weiss, sollte das auch ohne <strong>static</strong> funktionieren</p>
<p><strong>Datei main.cpp</strong></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;stdio.h&gt;
#include &quot;menue.h&quot;

using namespace std;

int main ()
{
	char title[30];
	int hoehe, laenge;

	printf (&quot;Name fuer das Menue: &quot;);
	gets ( title );
	printf (&quot;\n&quot;);

	printf (&quot;Laenge des Menues: &quot;);
	scanf(&quot;%d&quot;,&amp;laenge);
	printf (&quot;\n&quot;);

	printf (&quot;Hoehe des Menues: &quot;);
	scanf(&quot;%d&quot;,&amp;hoehe);
	printf (&quot;\n&quot;);

	system(&quot;cls&quot;);

	printf (&quot;Hoehe: %d Laenge: %d \n\n&quot;,hoehe,laenge);

	C_Menue::DrawMenue( laenge, hoehe, title );

	system(&quot;pause&quot;);
	return 0;
}
</code></pre>
<p><strong>Datei menue.h</strong></p>
<pre><code class="language-cpp">#include &lt;string&gt;

class C_Menue
{
public:
	void DrawMenue(int length, int height, std::string title);
};
</code></pre>
<p><strong>Datei menue.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;menue.h&quot;
#include &lt;iostream&gt;

void C_Menue::DrawMenue(int lenght, int height, std::string title)
{
	std::string title_p1;
	std::string title_print;
	int title_maxlen;

	for ( int i = 0; i &lt;= lenght; i++)
	{
		title_p1.append(&quot;\xCD&quot;);
	};

	title_print.append(&quot;\xC9&quot;+title_p1+&quot;\xB4 &quot; + title + &quot; \xC3&quot;+title_p1+&quot;\xBB&quot;);
	title_maxlen = title_print.length() - 2;
	title_print.append(&quot;\n&quot;);

	for ( i = 0; i &lt;= height; i++)
	{
		if (i == height)
		{
			title_print.append(&quot;\xC8&quot;);
			for ( int a = 0; a &lt;= title_maxlen-1; a++)
			{
				title_print.append(&quot;\xCD&quot;);
			}
			title_print.append(&quot;\xBC\n&quot;);
		}
		else
		{
			for ( int x = 0; x &lt;= title_maxlen; x++ )
			{
					if (x == 0)
					{
						title_print.append(&quot;\xBA&quot;);
					}
					if (x == title_maxlen)
					{
						title_print.append(&quot;\xBA\n&quot;);
					}
					else
					{
						title_print.append(&quot; &quot;);
					}
			}
		}
	};

	printf (&quot;%s&quot;,title_print.c_str());
}
</code></pre>
<p>€dit:<br />
Sobald ich der Deklaration ein <strong>static</strong> anführen lasse, läuft alles problemlos.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/174951/mvsc-6-0-problem-bei-deklaration-und-definition-von-methoden</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 22:44:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/174951.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Mar 2007 16:13:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [MVSC++6.0] Problem bei Deklaration und Definition von Methoden on Mon, 05 Mar 2007 16:17:47 GMT]]></title><description><![CDATA[<p>Moinsen Community !</p>
<p>Ich bin grade dabei mir selbst C++ beizubringen.<br />
So. Nun iss ja alles gut und schön, hab ich folgendes Problem:<br />
Beim versuch in der menue.cpp die Methode zu Definieren wirft der Compiler<br />
[MSVC++6.0] folgende Fehlermeldung aus:</p>
<blockquote>
<p>J:\Eigene Dateien\Meine Projekte\noname002\main.cpp(29) : error C2352: 'C_Menue::DrawMenue' : Unzulaessiger Aufruf einer nichtstatischen Member-Funktion<br />
j:\eigene dateien\meine projekte\noname002\menue.h(6) : Siehe Deklaration von 'DrawMenue'</p>
</blockquote>
<p>Warum muss ich eine statische Methode Deklarieren, damit ich sie später<br />
Definieren kann ?<br />
Soweit ich weiss, sollte das auch ohne <strong>static</strong> funktionieren</p>
<p><strong>Datei main.cpp</strong></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;stdio.h&gt;
#include &quot;menue.h&quot;

using namespace std;

int main ()
{
	char title[30];
	int hoehe, laenge;

	printf (&quot;Name fuer das Menue: &quot;);
	gets ( title );
	printf (&quot;\n&quot;);

	printf (&quot;Laenge des Menues: &quot;);
	scanf(&quot;%d&quot;,&amp;laenge);
	printf (&quot;\n&quot;);

	printf (&quot;Hoehe des Menues: &quot;);
	scanf(&quot;%d&quot;,&amp;hoehe);
	printf (&quot;\n&quot;);

	system(&quot;cls&quot;);

	printf (&quot;Hoehe: %d Laenge: %d \n\n&quot;,hoehe,laenge);

	C_Menue::DrawMenue( laenge, hoehe, title );

	system(&quot;pause&quot;);
	return 0;
}
</code></pre>
<p><strong>Datei menue.h</strong></p>
<pre><code class="language-cpp">#include &lt;string&gt;

class C_Menue
{
public:
	void DrawMenue(int length, int height, std::string title);
};
</code></pre>
<p><strong>Datei menue.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;menue.h&quot;
#include &lt;iostream&gt;

void C_Menue::DrawMenue(int lenght, int height, std::string title)
{
	std::string title_p1;
	std::string title_print;
	int title_maxlen;

	for ( int i = 0; i &lt;= lenght; i++)
	{
		title_p1.append(&quot;\xCD&quot;);
	};

	title_print.append(&quot;\xC9&quot;+title_p1+&quot;\xB4 &quot; + title + &quot; \xC3&quot;+title_p1+&quot;\xBB&quot;);
	title_maxlen = title_print.length() - 2;
	title_print.append(&quot;\n&quot;);

	for ( i = 0; i &lt;= height; i++)
	{
		if (i == height)
		{
			title_print.append(&quot;\xC8&quot;);
			for ( int a = 0; a &lt;= title_maxlen-1; a++)
			{
				title_print.append(&quot;\xCD&quot;);
			}
			title_print.append(&quot;\xBC\n&quot;);
		}
		else
		{
			for ( int x = 0; x &lt;= title_maxlen; x++ )
			{
					if (x == 0)
					{
						title_print.append(&quot;\xBA&quot;);
					}
					if (x == title_maxlen)
					{
						title_print.append(&quot;\xBA\n&quot;);
					}
					else
					{
						title_print.append(&quot; &quot;);
					}
			}
		}
	};

	printf (&quot;%s&quot;,title_print.c_str());
}
</code></pre>
<p>€dit:<br />
Sobald ich der Deklaration ein <strong>static</strong> anführen lasse, läuft alles problemlos.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239673</guid><dc:creator><![CDATA[Pyro Phoenix]]></dc:creator><pubDate>Mon, 05 Mar 2007 16:17:47 GMT</pubDate></item><item><title><![CDATA[Reply to [MVSC++6.0] Problem bei Deklaration und Definition von Methoden on Mon, 05 Mar 2007 16:59:56 GMT]]></title><description><![CDATA[<p>Jo ... hmm weil du halt ein Object von C_Menu erstellen musst ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239703</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 05 Mar 2007 16:59:56 GMT</pubDate></item><item><title><![CDATA[Reply to [MVSC++6.0] Problem bei Deklaration und Definition von Methoden on Mon, 05 Mar 2007 17:52:58 GMT]]></title><description><![CDATA[<p>Öhh ja klar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Erklärst du mir wie das geht ?<br />
Ich glaub soweit war ich noch ned.<br />
Bzw. Weiss ich grade mal nich was du meinst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239746</guid><dc:creator><![CDATA[Pyro Phoenix]]></dc:creator><pubDate>Mon, 05 Mar 2007 17:52:58 GMT</pubDate></item><item><title><![CDATA[Reply to [MVSC++6.0] Problem bei Deklaration und Definition von Methoden on Mon, 05 Mar 2007 18:36:54 GMT]]></title><description><![CDATA[<p>naja du hast sowieso nen komischen mischmasch da ...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;menue.h&quot;

int main ()
{
    std::string string_title;
    unsigned short hight = 0;
    unsigned short lenght = 0;

    std::cout &lt;&lt; &quot;Name fuer das Menue: &quot; &lt;&lt; std::flush;
    std::getline(std::cin, string_title);

    std::cout &lt;&lt; &quot;Laenge des Menues: &quot; &lt;&lt; std::flush;
    std::cin &gt;&gt; lenght;
    std::cout &lt;&lt; &quot;Hoehe des Menues: &quot; &lt;&lt; std::flush;
    std::cin &gt;&gt; hight;

    std::cout &lt;&lt; &quot;Hoehe: &quot; &lt;&lt; hight &lt;&lt; std::endl;
    std::cout &lt;&lt; &quot;Laenge: &quot; &lt;&lt; length &lt;&lt; std::endl;

    C_Menue menu;
    menu.DrawMenue(lenght, hight, title);

    return 0;
}
</code></pre>
<p>Und der Rest des Codes geht noch weniger -.- also da musse mal dringen was dran machen ^^</p>
<p>aja ... hab jetzt keine Fehlerabfrage falls kein unsigned short eingegeben wurde ... muss du noch machen ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239773</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Mon, 05 Mar 2007 18:36:54 GMT</pubDate></item><item><title><![CDATA[Reply to [MVSC++6.0] Problem bei Deklaration und Definition von Methoden on Mon, 05 Mar 2007 19:28:16 GMT]]></title><description><![CDATA[<p>lol kann mich mal jemand treten ?</p>
<pre><code class="language-cpp">C_Menue menu; 
    menu.DrawMenue(lenght, hight, title);
</code></pre>
<p>Hab ich ja glatt vergessen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<p>THX</p>
<p>hmm die abfrage iss ja eh nur provisorisch ...<br />
die brauch ich nur zum testen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239808</guid><dc:creator><![CDATA[Pyro Phoenix]]></dc:creator><pubDate>Mon, 05 Mar 2007 19:28:16 GMT</pubDate></item></channel></rss>