<?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[Undeklarierte Funktion]]></title><description><![CDATA[<p>Hallo erstmal,</p>
<p>ich habe mal wieder ein Problem mit meinem Programm. Der Compiler sagt mir, dass eine Funktion undeklariert sei, die ich aber in der Headerdatei deklariert habe. Hier meine Dateien:</p>
<p>Konsolengame.cpp:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &quot;mensch.h&quot;

using namespace std;

int randy ( int area );

int main()
{
    Mensch nexus;
    Mensch gorn;

    nexus.erzeuge (&quot;Nexus&quot; , 100 , 50);
    gorn.erzeuge (&quot;Gorn&quot; , 100 , 50);

    while ( true ) {
                      SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
          cout&lt;&lt;&quot;Zu wirkender Zauber:\n&quot;;
          string pspell;
          cin&gt;&gt;pspell;
          cout&lt;&lt;&quot;\nZiel:\n&quot;;
          string ptarget;
          cin&gt;&gt;ptarget;

                  system(&quot;cls&quot;);

                  int manacheck;

manacheck = checkmana(pspell);

                  if (manacheck == 0) {

          nexus.nzaubern (pspell , ptarget);
          if (pspell == &quot;Feuerball&quot;) {
                     gorn.dellife(20);
                     } else if (pspell == &quot;Feuerpfeil&quot;) {
                     gorn.dellife(10);
                     }
          int kispell;
        kispell = randy (2);

            // system(&quot;COLOR 04&quot;);
        if (kispell == 0) {
        gorn.gzaubern( &quot;Feuerpfeil&quot; , &quot;Nexus&quot; );
        nexus.dellife(10);
        } else if (kispell == 1) {
        gorn.gzaubern( &quot;Feuerball&quot; , &quot;Nexus&quot; );
        nexus.dellife(20);
        }

        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
        cout&lt;&lt;&quot;NEXUS\n&quot;;
        nexus.stat(1);
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
        cout&lt;&lt;&quot;\n\nGORN\n&quot;;
        gorn.stat(0);

        int doap;
               int doag;
               doap = nexus.checkstatus();
               doag = gorn.checkstatus();

               if (doap == 1) {
                       cout&lt;&lt;&quot;Nexus ist tot! Das Programm wird nun beendet!&quot;;
                       Sleep(5000);
//                       return 0;
               }
               if (doag == 1) {
                       cout&lt;&lt;&quot;Gorn ist tot! Das Programm wird nun beendet!&quot;;
                       Sleep(5000);
//                       return 0;
                       }

                       if (doag == 1 || doap == 1) {
                                return 0;
                       }
            } else {
            cout&lt;&lt;&quot;Nicht genug Mana. Wiederholung des Zuges!&quot;;
            }

        cout&lt;&lt;&quot;\n\n\n\n&quot;;
        }
}

int randy ( int area ) {
    int rn = time(0)%area;
    return rn;
    }
</code></pre>
<p>mensch.h:</p>
<pre><code>#include &lt;iostream&gt;

#ifndef _MENSCH_H_
#define _MENSCH_H_

using namespace std;

          int i = 0;

class Mensch {
      public:
      char name[30];
      int life;
      int mana;
      void erzeuge (const char* n , int f , int m);
      void stat( int l );
      void nzaubern ( const string spell , const string b );
      void gzaubern ( const string spell , const string b );
      void lp (int d);
      void dellife ( int lip );
      int checkstatus ( );
      int checkmana( const string cspell );
      };

void Mensch::erzeuge(const char* n , int f , int m) {
   strncpy( name, n, sizeof(name)-1 );
   name[sizeof(name)] = '\0';
   life = f;
   mana = m;
}

void Mensch::stat ( int l ) {
     cout&lt;&lt;&quot;Lebenspunkte: &quot;&lt;&lt;life&lt;&lt;&quot;\n&quot;;
     if (l == 1) {
     cout&lt;&lt;&quot;Mana: &quot;&lt;&lt;mana&lt;&lt;&quot;\n&quot;;
     }
}

void Mensch::nzaubern ( const string x , const string b ) {
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
     cout&lt;&lt;name &lt;&lt; &quot; wirkt den Zauber &quot; &lt;&lt; x &lt;&lt; &quot; auf &quot; &lt;&lt; b &lt;&lt;&quot;\n\n&quot;;
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
              if (x == &quot;Feuerball&quot;) {
                    mana -= 10;

                    } else if (x == &quot;Feuerpfeil&quot;) {
                    mana -= 5;
                    }
                    }

void Mensch::gzaubern ( const string x , const string b ) {
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
     cout&lt;&lt;name &lt;&lt; &quot; wirkt den Zauber &quot; &lt;&lt; x &lt;&lt; &quot; auf &quot; &lt;&lt; b &lt;&lt;&quot;\n\n&quot;;
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
              if (x == &quot;Feuerball&quot;) {
                    mana -= 10;

                    } else if (x == &quot;Feuerpfeil&quot;) {
                    mana -= 5;
                    }                    

     }

void Mensch::lp (int d) {
     life -= d;
     if (life &lt;= 0) {
              life = 0;
     }
     cout&lt;&lt;name &lt;&lt; &quot; hat &quot; &lt;&lt; life &lt;&lt; &quot; Lebenspunkte!\n&quot;;
     }

     void Mensch::dellife ( int lip ) {

          life -= lip;   

             }

int Mensch::checkstatus ( ) {
    if (life == 0) {
    return 1;
    } else {
    return 0;
    }
}

int Mensch::checkmana(string cspell) {
    int back;
    if (cspell == &quot;Feuerball&quot;) {
               if (mana &lt; 10) {
                        back = 1;
               }
    }
    if (cspell == &quot;Feuerpfeil&quot;) {
               if (mana &lt; 5) {
                        back = 1;
               }
    }         
return back;
}

#endif
</code></pre>
<p>Es sieht da noch ziemlich unaufgeräumt aus, aber ich denke das hindert euch bei diesem Problem nicht.<br />
Das ganze soll ein Pseude-Konsolenspiel werden, die angeblich undeklarierte Funktion ist checkmana und der Fehler tritt in der Datei Konsolengame.cpp in der Zeile 30 auf, also da, wo die Funktion aufgerufen wird.</p>
<p>Hoffe auf schnelle Hilfe</p>
<p>mfG Alemarius Nexus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/186432/undeklarierte-funktion</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 08:45:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/186432.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Jul 2007 22:06:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Undeklarierte Funktion on Sun, 08 Jul 2007 22:06:11 GMT]]></title><description><![CDATA[<p>Hallo erstmal,</p>
<p>ich habe mal wieder ein Problem mit meinem Programm. Der Compiler sagt mir, dass eine Funktion undeklariert sei, die ich aber in der Headerdatei deklariert habe. Hier meine Dateien:</p>
<p>Konsolengame.cpp:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &quot;mensch.h&quot;

using namespace std;

int randy ( int area );

int main()
{
    Mensch nexus;
    Mensch gorn;

    nexus.erzeuge (&quot;Nexus&quot; , 100 , 50);
    gorn.erzeuge (&quot;Gorn&quot; , 100 , 50);

    while ( true ) {
                      SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
          cout&lt;&lt;&quot;Zu wirkender Zauber:\n&quot;;
          string pspell;
          cin&gt;&gt;pspell;
          cout&lt;&lt;&quot;\nZiel:\n&quot;;
          string ptarget;
          cin&gt;&gt;ptarget;

                  system(&quot;cls&quot;);

                  int manacheck;

manacheck = checkmana(pspell);

                  if (manacheck == 0) {

          nexus.nzaubern (pspell , ptarget);
          if (pspell == &quot;Feuerball&quot;) {
                     gorn.dellife(20);
                     } else if (pspell == &quot;Feuerpfeil&quot;) {
                     gorn.dellife(10);
                     }
          int kispell;
        kispell = randy (2);

            // system(&quot;COLOR 04&quot;);
        if (kispell == 0) {
        gorn.gzaubern( &quot;Feuerpfeil&quot; , &quot;Nexus&quot; );
        nexus.dellife(10);
        } else if (kispell == 1) {
        gorn.gzaubern( &quot;Feuerball&quot; , &quot;Nexus&quot; );
        nexus.dellife(20);
        }

        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
        cout&lt;&lt;&quot;NEXUS\n&quot;;
        nexus.stat(1);
                SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
        cout&lt;&lt;&quot;\n\nGORN\n&quot;;
        gorn.stat(0);

        int doap;
               int doag;
               doap = nexus.checkstatus();
               doag = gorn.checkstatus();

               if (doap == 1) {
                       cout&lt;&lt;&quot;Nexus ist tot! Das Programm wird nun beendet!&quot;;
                       Sleep(5000);
//                       return 0;
               }
               if (doag == 1) {
                       cout&lt;&lt;&quot;Gorn ist tot! Das Programm wird nun beendet!&quot;;
                       Sleep(5000);
//                       return 0;
                       }

                       if (doag == 1 || doap == 1) {
                                return 0;
                       }
            } else {
            cout&lt;&lt;&quot;Nicht genug Mana. Wiederholung des Zuges!&quot;;
            }

        cout&lt;&lt;&quot;\n\n\n\n&quot;;
        }
}

int randy ( int area ) {
    int rn = time(0)%area;
    return rn;
    }
</code></pre>
<p>mensch.h:</p>
<pre><code>#include &lt;iostream&gt;

#ifndef _MENSCH_H_
#define _MENSCH_H_

using namespace std;

          int i = 0;

class Mensch {
      public:
      char name[30];
      int life;
      int mana;
      void erzeuge (const char* n , int f , int m);
      void stat( int l );
      void nzaubern ( const string spell , const string b );
      void gzaubern ( const string spell , const string b );
      void lp (int d);
      void dellife ( int lip );
      int checkstatus ( );
      int checkmana( const string cspell );
      };

void Mensch::erzeuge(const char* n , int f , int m) {
   strncpy( name, n, sizeof(name)-1 );
   name[sizeof(name)] = '\0';
   life = f;
   mana = m;
}

void Mensch::stat ( int l ) {
     cout&lt;&lt;&quot;Lebenspunkte: &quot;&lt;&lt;life&lt;&lt;&quot;\n&quot;;
     if (l == 1) {
     cout&lt;&lt;&quot;Mana: &quot;&lt;&lt;mana&lt;&lt;&quot;\n&quot;;
     }
}

void Mensch::nzaubern ( const string x , const string b ) {
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
     cout&lt;&lt;name &lt;&lt; &quot; wirkt den Zauber &quot; &lt;&lt; x &lt;&lt; &quot; auf &quot; &lt;&lt; b &lt;&lt;&quot;\n\n&quot;;
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
              if (x == &quot;Feuerball&quot;) {
                    mana -= 10;

                    } else if (x == &quot;Feuerpfeil&quot;) {
                    mana -= 5;
                    }
                    }

void Mensch::gzaubern ( const string x , const string b ) {
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
     cout&lt;&lt;name &lt;&lt; &quot; wirkt den Zauber &quot; &lt;&lt; x &lt;&lt; &quot; auf &quot; &lt;&lt; b &lt;&lt;&quot;\n\n&quot;;
     SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),  FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
              if (x == &quot;Feuerball&quot;) {
                    mana -= 10;

                    } else if (x == &quot;Feuerpfeil&quot;) {
                    mana -= 5;
                    }                    

     }

void Mensch::lp (int d) {
     life -= d;
     if (life &lt;= 0) {
              life = 0;
     }
     cout&lt;&lt;name &lt;&lt; &quot; hat &quot; &lt;&lt; life &lt;&lt; &quot; Lebenspunkte!\n&quot;;
     }

     void Mensch::dellife ( int lip ) {

          life -= lip;   

             }

int Mensch::checkstatus ( ) {
    if (life == 0) {
    return 1;
    } else {
    return 0;
    }
}

int Mensch::checkmana(string cspell) {
    int back;
    if (cspell == &quot;Feuerball&quot;) {
               if (mana &lt; 10) {
                        back = 1;
               }
    }
    if (cspell == &quot;Feuerpfeil&quot;) {
               if (mana &lt; 5) {
                        back = 1;
               }
    }         
return back;
}

#endif
</code></pre>
<p>Es sieht da noch ziemlich unaufgeräumt aus, aber ich denke das hindert euch bei diesem Problem nicht.<br />
Das ganze soll ein Pseude-Konsolenspiel werden, die angeblich undeklarierte Funktion ist checkmana und der Fehler tritt in der Datei Konsolengame.cpp in der Zeile 30 auf, also da, wo die Funktion aufgerufen wird.</p>
<p>Hoffe auf schnelle Hilfe</p>
<p>mfG Alemarius Nexus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321079</guid><dc:creator><![CDATA[Alemarius Nexus]]></dc:creator><pubDate>Sun, 08 Jul 2007 22:06:11 GMT</pubDate></item><item><title><![CDATA[Reply to Undeklarierte Funktion on Sun, 08 Jul 2007 22:26:15 GMT]]></title><description><![CDATA[<p>Kannst Methode &quot;Mensch::checkmana ()&quot; nur zusammen mit einer Instanz von &quot;Mensch&quot; aufrufen.<br />
Entweder &quot;nexus.checkmana (pspell)&quot; oder &quot;gorn.checkmana (pspell)&quot;.<br />
<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/1321081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321081</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 08 Jul 2007 22:26:15 GMT</pubDate></item><item><title><![CDATA[Reply to Undeklarierte Funktion on Mon, 09 Jul 2007 07:56:09 GMT]]></title><description><![CDATA[<p>Und für C++-Code sind die Cpp-Codetags besser als die normalen Code-Tags..<br />
Also statt</p>
<pre><code>und
</code></pre>
<p>einfach</p>
<pre><code class="language-cpp">und
</code></pre>
<p>verwenden <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/1321202</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321202</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Mon, 09 Jul 2007 07:56:09 GMT</pubDate></item><item><title><![CDATA[Reply to Undeklarierte Funktion on Mon, 09 Jul 2007 08:03:37 GMT]]></title><description><![CDATA[<p>Dummer Fehler, darauf hätte ich auch kommen können.</p>
<p>Wie auch immer, danke für die Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321207</guid><dc:creator><![CDATA[Alemarius Nexus]]></dc:creator><pubDate>Mon, 09 Jul 2007 08:03:37 GMT</pubDate></item></channel></rss>