<?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[Dateistruktur]]></title><description><![CDATA[<p>[gelöst]</p>
<p>Hallo,<br />
ich habe nicht viel Erfahrung mit c++, wollte aber das Programm Eliza in kleinere Dateien zerlegen, doch das gelingt mir nicht, weil ich nicht weiß wie das genau funktioniert. Die einzelne cpp-Datei wird ohne Probleme kompiliert. Versuche ich meine Aufteilung bekomme ich tausende von Fehlermeldungen.</p>
<p>Hoffe ihr könnt mir weiterhelfen. Gegooglet habe ich auch schon, konnte aber nichts finden, weil ich nicht genau weiß mit welchen Suchbegriffen ich suchen soll.</p>
<p>Der Code:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using namespace std;

class tStichwort {
public:
    string Wort;
    int ID;
};

tStichwort Stichwoerter[] = {
    {&quot;Bruder&quot;, 1}, {&quot;Vater&quot;, 1}, {&quot;Sohn&quot;, 1}, {&quot;Opa&quot;, 1},
    { &quot;Freund&quot;, 1}, { &quot;Mutter&quot;, 2}, {&quot;Schwester&quot;, 2},
    { &quot;Tochter&quot;, 2}, {&quot;Oma&quot;, 2}, 
    {&quot;Gewalt&quot;, 3}, {&quot;Druck&quot;, 3}, {&quot;Schweigen&quot;, 3}
                 };

class tAntwort {
public:
    long Aufrufe;
    string Antwort;
};

tAntwort Antworten[] = {
{0, &quot;Dein $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deinem $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deinem $!&quot;},
{0, &quot;Deine $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deiner $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deiner $!&quot;},
{0, &quot;$ ist keine echte Lösung.&quot;},
{0, &quot;Es ist nicht gut, mit $ zu leben.&quot;},
{0, &quot;Sollte die Welt nicht auf $ verzichten?&quot;},
{0, &quot;Was bedeutet das eigentlich für Dich: $?&quot;}
                       };

tAntwort Phrasen[] = {
    { 0, &quot;Ich verstehe Deine Zurückhaltung.&quot; },
    { 0, &quot;Solltest Du nicht offener von Dir reden?&quot; },
    { 0, &quot;Was meinst Du ist denn die Ursache von all dem?&quot; },
    { 0, &quot;Kannst Du etwas präziser werden?&quot; },
    { 0, &quot;Du solltest nicht alles in Dich hineinfressen.&quot; },
    { 0, &quot;Fühlst Du Dich in dieser Hinsicht unsicher?&quot; }
                       };

class tBindung {
public:
    long WortID;
    long AntwortID;
};

tBindung Bindungen[] = {
   {1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5},
   {3, 6}, {3, 7}, {3, 8}, {1, 9}, {2, 9}, {3, 9}
                       };

bool istBuchstabe(char Zeichen)
{
    if (Zeichen&gt;='a' &amp;&amp; Zeichen&lt;='z') return true;
    if (Zeichen&gt;='A' &amp;&amp; Zeichen&lt;='Z') return true;
    // Mit UTF-8 wird das mit den Umlauten nicht so einfach
    return false;
}

void zerlegeInWoerter(const string &amp;Satz, vector&lt;string&gt; &amp;Woerter)
{
    int Laenge = Satz.length();
    int Pos = 0;
    int Anfang;
    Woerter.clear();
    while (Pos&lt;Laenge) {
        while (Pos&lt;Laenge &amp;&amp; !istBuchstabe(Satz[Pos])) Pos++;
        Anfang = Pos;
        while (Pos&lt;Laenge &amp;&amp; istBuchstabe(Satz[Pos])) Pos++;
        Woerter.push_back(Satz.substr(Anfang, Pos-Anfang));
    }
}

long holeAntwort(long WortID)
{
    long min=999999;
    long minID = -1;
    long AntwortID;
    long MaxBindungen=sizeof(Bindungen)/sizeof(Bindungen[0]);
    for (long bi=0; bi&lt;MaxBindungen; ++bi) {
        if (Bindungen[bi].WortID==WortID) {
            AntwortID = Bindungen[bi].AntwortID;
            if (min&gt;Antworten[AntwortID].Aufrufe) {
                minID=AntwortID;
                min=Antworten[AntwortID].Aufrufe;
                --Antworten[AntwortID].Aufrufe;
            }
        }
    }
    return minID;
}

void ersetzePlatzHalter(string &amp;Antwort, const string &amp;Wort)
{
    unsigned long pos = Antwort.find(&quot;$&quot;);
    if (pos!=string::npos) {
        Antwort.replace(pos, 1, Wort);
    }
}

long holePhrase()
{
    long min=999999;
    long minID = -1;
    long MaxPhrasen = sizeof(Phrasen)/sizeof(Phrasen[0]);
    for (long i=0; i&lt;MaxPhrasen; ++i) {
        if (min&gt;Phrasen[i].Aufrufe) {
            minID=i;
            min=Phrasen[i].Aufrufe;
            --Phrasen[i].Aufrufe;
        }
    }
    return minID;
}

void sucheNachAntwort(vector&lt;string&gt; &amp;Woerter, string&amp; Antwort)
{
    long MaxStichwoerter=sizeof(Stichwoerter)
                        /sizeof(Stichwoerter[0]);
    vector&lt;string&gt;::iterator it;
    for (it=Woerter.begin(); it!=Woerter.end(); ++it) {
        for (long wi=0; wi&lt;MaxStichwoerter; ++wi) {
            if (*it == Stichwoerter[wi].Wort) {
                long ID = Stichwoerter[wi].ID;
                long AntwortID = holeAntwort(ID);
                // Nun sollten wir eine ID haben
                if (AntwortID&gt;=0) {
                    Antwort = Antworten[AntwortID].Antwort;
                    ersetzePlatzHalter(Antwort, *it);
                    // Diese Antwort etwas zurückstellen
                    Antworten[AntwortID].Aufrufe+=10;
                    // wir gehen mal einfach
                    return;
                }
            }
        }
    }
    // Kein Stichwort gefunden. Wir faseln...
    long AntwortID = holePhrase();
    Antwort = Phrasen[AntwortID].Antwort;
    // Diese Antwort etwas zurückstellen
    Phrasen[AntwortID].Aufrufe+=10;
}

int main()
{
    string Aussage;
    while (true) {
        getline(cin, Aussage);
        vector&lt;string&gt; Woerter;
        zerlegeInWoerter(Aussage, Woerter);
        string Antwort;
        sucheNachAntwort(Woerter, Antwort);
        cout &lt;&lt; Antwort &lt;&lt; endl;
    }
}
</code></pre>
<p>Kann man hier auch Dateien hochladen?? Würde gerne meine Aufteilung zeigen, um die Fehler zu sehen.<br />
Meine Aufteilung: main.cpp, klassen.h, antworten.cpp, bindungen.cpp, phrasen.cpp, stichwoerter.cpp und funktionen.cpp</p>
<p>Viele Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/280717/dateistruktur</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 00:21:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/280717.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Jan 2011 08:55:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 15:49:41 GMT]]></title><description><![CDATA[<p>[gelöst]</p>
<p>Hallo,<br />
ich habe nicht viel Erfahrung mit c++, wollte aber das Programm Eliza in kleinere Dateien zerlegen, doch das gelingt mir nicht, weil ich nicht weiß wie das genau funktioniert. Die einzelne cpp-Datei wird ohne Probleme kompiliert. Versuche ich meine Aufteilung bekomme ich tausende von Fehlermeldungen.</p>
<p>Hoffe ihr könnt mir weiterhelfen. Gegooglet habe ich auch schon, konnte aber nichts finden, weil ich nicht genau weiß mit welchen Suchbegriffen ich suchen soll.</p>
<p>Der Code:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using namespace std;

class tStichwort {
public:
    string Wort;
    int ID;
};

tStichwort Stichwoerter[] = {
    {&quot;Bruder&quot;, 1}, {&quot;Vater&quot;, 1}, {&quot;Sohn&quot;, 1}, {&quot;Opa&quot;, 1},
    { &quot;Freund&quot;, 1}, { &quot;Mutter&quot;, 2}, {&quot;Schwester&quot;, 2},
    { &quot;Tochter&quot;, 2}, {&quot;Oma&quot;, 2}, 
    {&quot;Gewalt&quot;, 3}, {&quot;Druck&quot;, 3}, {&quot;Schweigen&quot;, 3}
                 };

class tAntwort {
public:
    long Aufrufe;
    string Antwort;
};

tAntwort Antworten[] = {
{0, &quot;Dein $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deinem $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deinem $!&quot;},
{0, &quot;Deine $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deiner $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deiner $!&quot;},
{0, &quot;$ ist keine echte Lösung.&quot;},
{0, &quot;Es ist nicht gut, mit $ zu leben.&quot;},
{0, &quot;Sollte die Welt nicht auf $ verzichten?&quot;},
{0, &quot;Was bedeutet das eigentlich für Dich: $?&quot;}
                       };

tAntwort Phrasen[] = {
    { 0, &quot;Ich verstehe Deine Zurückhaltung.&quot; },
    { 0, &quot;Solltest Du nicht offener von Dir reden?&quot; },
    { 0, &quot;Was meinst Du ist denn die Ursache von all dem?&quot; },
    { 0, &quot;Kannst Du etwas präziser werden?&quot; },
    { 0, &quot;Du solltest nicht alles in Dich hineinfressen.&quot; },
    { 0, &quot;Fühlst Du Dich in dieser Hinsicht unsicher?&quot; }
                       };

class tBindung {
public:
    long WortID;
    long AntwortID;
};

tBindung Bindungen[] = {
   {1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5},
   {3, 6}, {3, 7}, {3, 8}, {1, 9}, {2, 9}, {3, 9}
                       };

bool istBuchstabe(char Zeichen)
{
    if (Zeichen&gt;='a' &amp;&amp; Zeichen&lt;='z') return true;
    if (Zeichen&gt;='A' &amp;&amp; Zeichen&lt;='Z') return true;
    // Mit UTF-8 wird das mit den Umlauten nicht so einfach
    return false;
}

void zerlegeInWoerter(const string &amp;Satz, vector&lt;string&gt; &amp;Woerter)
{
    int Laenge = Satz.length();
    int Pos = 0;
    int Anfang;
    Woerter.clear();
    while (Pos&lt;Laenge) {
        while (Pos&lt;Laenge &amp;&amp; !istBuchstabe(Satz[Pos])) Pos++;
        Anfang = Pos;
        while (Pos&lt;Laenge &amp;&amp; istBuchstabe(Satz[Pos])) Pos++;
        Woerter.push_back(Satz.substr(Anfang, Pos-Anfang));
    }
}

long holeAntwort(long WortID)
{
    long min=999999;
    long minID = -1;
    long AntwortID;
    long MaxBindungen=sizeof(Bindungen)/sizeof(Bindungen[0]);
    for (long bi=0; bi&lt;MaxBindungen; ++bi) {
        if (Bindungen[bi].WortID==WortID) {
            AntwortID = Bindungen[bi].AntwortID;
            if (min&gt;Antworten[AntwortID].Aufrufe) {
                minID=AntwortID;
                min=Antworten[AntwortID].Aufrufe;
                --Antworten[AntwortID].Aufrufe;
            }
        }
    }
    return minID;
}

void ersetzePlatzHalter(string &amp;Antwort, const string &amp;Wort)
{
    unsigned long pos = Antwort.find(&quot;$&quot;);
    if (pos!=string::npos) {
        Antwort.replace(pos, 1, Wort);
    }
}

long holePhrase()
{
    long min=999999;
    long minID = -1;
    long MaxPhrasen = sizeof(Phrasen)/sizeof(Phrasen[0]);
    for (long i=0; i&lt;MaxPhrasen; ++i) {
        if (min&gt;Phrasen[i].Aufrufe) {
            minID=i;
            min=Phrasen[i].Aufrufe;
            --Phrasen[i].Aufrufe;
        }
    }
    return minID;
}

void sucheNachAntwort(vector&lt;string&gt; &amp;Woerter, string&amp; Antwort)
{
    long MaxStichwoerter=sizeof(Stichwoerter)
                        /sizeof(Stichwoerter[0]);
    vector&lt;string&gt;::iterator it;
    for (it=Woerter.begin(); it!=Woerter.end(); ++it) {
        for (long wi=0; wi&lt;MaxStichwoerter; ++wi) {
            if (*it == Stichwoerter[wi].Wort) {
                long ID = Stichwoerter[wi].ID;
                long AntwortID = holeAntwort(ID);
                // Nun sollten wir eine ID haben
                if (AntwortID&gt;=0) {
                    Antwort = Antworten[AntwortID].Antwort;
                    ersetzePlatzHalter(Antwort, *it);
                    // Diese Antwort etwas zurückstellen
                    Antworten[AntwortID].Aufrufe+=10;
                    // wir gehen mal einfach
                    return;
                }
            }
        }
    }
    // Kein Stichwort gefunden. Wir faseln...
    long AntwortID = holePhrase();
    Antwort = Phrasen[AntwortID].Antwort;
    // Diese Antwort etwas zurückstellen
    Phrasen[AntwortID].Aufrufe+=10;
}

int main()
{
    string Aussage;
    while (true) {
        getline(cin, Aussage);
        vector&lt;string&gt; Woerter;
        zerlegeInWoerter(Aussage, Woerter);
        string Antwort;
        sucheNachAntwort(Woerter, Antwort);
        cout &lt;&lt; Antwort &lt;&lt; endl;
    }
}
</code></pre>
<p>Kann man hier auch Dateien hochladen?? Würde gerne meine Aufteilung zeigen, um die Fehler zu sehen.<br />
Meine Aufteilung: main.cpp, klassen.h, antworten.cpp, bindungen.cpp, phrasen.cpp, stichwoerter.cpp und funktionen.cpp</p>
<p>Viele Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009080</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 15:49:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 09:00:54 GMT]]></title><description><![CDATA[<p>Es wird vermutlich auf fehlende Deklarationen, Zirkelbezüge usw. hinauslaufen, aber poste bitte mal die Fehlermeldungen, dann kann man zu jeder was Genaues sagen.</p>
<p>Btw, wenn du lernen willst, wie du ein Programm korrekt und sinnvoll auf mehrere Dateien aufteilen kannst, solltest du das vielleicht erst mal an einem eigenen Programm versuchen. Ich schätze, dass du auf diesem Weg eher ein Verständnis für die Sache entwickeln würdest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009084</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 20 Jan 2011 09:00:54 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 09:05:23 GMT]]></title><description><![CDATA[<p>Danke dir, ich werd es auch mit eigenem Code versuchen.</p>
<p>Die Fehlermeldung:</p>
<pre><code class="language-cpp">In file included from main.cpp:4:
klassen.h:8: error: ‘string’ does not name a type
klassen.h:15: error: ‘string’ does not name a type
main.cpp: In function ‘int main()’:
main.cpp:13: error: ‘zerlegeInWoerter’ was not declared in this scope
main.cpp:15: error: ‘sucheNachAntwort’ was not declared in this scope
In file included from antworten.cpp:1:
klassen.h:8: error: ‘string’ does not name a type
klassen.h:15: error: ‘string’ does not name a type
antworten.cpp:8: error: expected ‘}’ before ‘{’ token
antworten.cpp:8: error: too many initializers for ‘tAntwort’
antworten.cpp:8: error: too many initializers for ‘tAntwort’
antworten.cpp:8: error: too many initializers for ‘tAntwort’
antworten.cpp:8: error: expected ‘,’ or ‘;’ before ‘{’ token
antworten.cpp:8: error: expected unqualified-id before ‘,’ token
antworten.cpp:9: error: expected unqualified-id before ‘{’ token
antworten.cpp:9: error: expected unqualified-id before ‘,’ token
antworten.cpp:10: error: expected unqualified-id before ‘{’ token
antworten.cpp:12: error: expected unqualified-id before ‘{’ token
antworten.cpp:13: error: expected unqualified-id before ‘{’ token
antworten.cpp:14: error: expected unqualified-id before ‘{’ token
antworten.cpp:16: error: expected unqualified-id before ‘{’ token
antworten.cpp:17: error: expected declaration before ‘}’ token
In file included from bindungen.cpp:1:
klassen.h:8: error: ‘string’ does not name a type
klassen.h:15: error: ‘string’ does not name a type
In file included from phrasen.cpp:1:
klassen.h:8: error: ‘string’ does not name a type
klassen.h:15: error: ‘string’ does not name a type
phrasen.cpp:7: error: expected ‘}’ before ‘{’ token
phrasen.cpp:7: error: too many initializers for ‘tAntwort’
phrasen.cpp:7: error: too many initializers for ‘tAntwort’
phrasen.cpp:7: error: too many initializers for ‘tAntwort’
phrasen.cpp:7: error: expected ‘,’ or ‘;’ before ‘{’ token
phrasen.cpp:7: error: expected unqualified-id before ‘,’ token
phrasen.cpp:8: error: expected unqualified-id before ‘{’ token
phrasen.cpp:8: error: expected unqualified-id before ‘,’ token
phrasen.cpp:9: error: expected unqualified-id before ‘{’ token
phrasen.cpp:10: error: expected declaration before ‘}’ token
In file included from stichwoerter.cpp:1:
klassen.h:8: error: ‘string’ does not name a type
klassen.h:15: error: ‘string’ does not name a type
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: too many initializers for ‘tStichwort’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
stichwoerter.cpp:7: error: invalid conversion from ‘const char*’ to ‘int’
In file included from funktionen.cpp:4:
klassen.h:8: error: ‘string’ does not name a type
klassen.h:15: error: ‘string’ does not name a type
funktionen.cpp: In function ‘long int holeAntwort(long int)’:
funktionen.cpp:33: error: ‘Bindungen’ was not declared in this scope
funktionen.cpp:37: error: ‘Antworten’ was not declared in this scope
funktionen.cpp: In function ‘long int holePhrase()’:
funktionen.cpp:59: error: ‘Phrasen’ was not declared in this scope
funktionen.cpp: In function ‘void sucheNachAntwort(std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::string&amp;)’:
funktionen.cpp:72: error: ‘Stichwoerter’ was not declared in this scope
funktionen.cpp:82: error: ‘Antworten’ was not declared in this scope
funktionen.cpp:94: error: ‘Phrasen’ was not declared in this scope
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009086</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 09:05:23 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 09:19:21 GMT]]></title><description><![CDATA[<p>Meine falsche Ordnung, wollte erstmal das ganze weglassen weil es zu viel wird, aber ich denke es ist doch besser, um zu sehen was ich falsch gemacht habe:</p>
<p>main.cpp:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;klassen.h&quot;

using namespace std;

int main( void ) {
  string Aussage;
  while( true ) {
    getline( cin, Aussage );
    vector&lt;string&gt; Woerter;
    zerlegeInWoerter( Aussage, Woerter );
    string Antwort;
    sucheNachAntwort( Woerter, Antwort );
    cout &lt;&lt; Antwort &lt;&lt; endl;
  }

  return 0;
}
</code></pre>
<p>klassen.h:</p>
<pre><code class="language-cpp">#ifndef _EKLASSEN_H_
#define _EKLASSEN_H_

#include &lt;string&gt;

class tStichwort {
  public:
    string Wort;
    int ID;
};

class tAntwort {
  public:
    long Aufrufe;
    string Antwort;
};

class tBindung {
  public:
    long WortID;
    long AntwortID;
};

#endif
</code></pre>
<p>antworten.cpp:</p>
<pre><code class="language-cpp">#include &quot;klassen.h&quot;

tAntwort Antworten[] = {
  {0, &quot;Dein $ ist Dir sehr wichtif, nicht wahr?&quot;},
  {0, &quot;Hättest Du nicht darüber mit Deinem $ sprechen sollen?&quot;},
  {0, &quot;Erzähle mehr über Deine Beziehung zu Deinem $!&quot;}

  {0, &quot;Deine $ ist Dir sehr wichtif, nicht wahr?&quot;},
  {0, &quot;Hättest Du nicht darüber mit Deiner $ sprechen sollen?&quot;},
  {0, &quot;Erzähle mehr über Deine Beziehung zu Deiner $!&quot;}

  {0 ,&quot;$ ist keine echte Lösung.&quot;}
  {0, &quot;Es ist nich gut mit $ zu leben.&quot;}
  {0, &quot;Sollte die Welt nicht auf $ verzichten?&quot;}

  {0, &quot;Was bedeutet das eigentlich für Dich: $?&quot;}
};
</code></pre>
<p>bindungen.cpp:</p>
<pre><code class="language-cpp">#include &quot;klassen.h&quot;

tBindung Bindungen[] = {
  {1, 0}, {1, 1}, {1, 2},
  {2, 3}, {2, 4}, {2, 5},
  {3, 6}, {3, 7}, {3, 8},
  {1, 9}, {2, 9}, {3, 9}
};
</code></pre>
<p>phrasen.cpp:</p>
<pre><code class="language-cpp">#include &quot;klassen.h&quot;

tAntwort Phrasen[] = {
  {0, &quot;Ich verstehe Deine Zurückhaltung.&quot;},
  {0, &quot;Solltest Du nicht offener von Die reden?&quot;},
  {0, &quot;Was meinst Du, ist denn die Ursache von all dem?&quot;}
  {0, &quot;Kannst Du etwas präziser werden?&quot;},
  {0, &quot;Du solltest nicht alles in Dich hineinfressen.&quot;},
  {0, &quot;Fühlst Du Dich in dieser Hinsicht unsicher?&quot;}
};
</code></pre>
<p>stichwoerter.cpp:</p>
<pre><code class="language-cpp">#include &quot;klassen.h&quot;

tStichwort Stichwoerter[] = {
  {&quot;Bruder&quot;, 1}, {&quot;Vater&quot;, 1}, {&quot;Sohn&quot;, 1}, {&quot;Opa&quot;, 1}, {&quot;Freund&quot;, 1},
  {&quot;Mutter&quot;, 2}, {&quot;Schwester&quot;, 2}, {&quot;Tochter&quot;, 2}, {&quot;Oma&quot;, 2},
  {&quot;Gewalt&quot;, 3}, {&quot;Druck&quot;, 3}, {&quot;Schweigen&quot;, 3}
};
</code></pre>
<p>funktionen.cpp:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;klassen.h&quot;

using namespace std;

bool istBuchstabe( char Zeichen ) {
  if( Zeichen&gt;='a' &amp;&amp; Zeichen&lt;='z' ) return true;
  if( Zeichen&gt;='A' &amp;&amp; Zeichen&lt;='Z' ) return true;
  return false;
}

void zerlegeInWoerter( const string &amp;Satz, vector&lt;string&gt; &amp;Woerter ) {
  int Laenge = Satz.length();
  int Pos = 0;
  int Anfang;
  Woerter.clear();
  while( Pos&lt;Laenge ) {
    while( Pos&lt;Laenge &amp;&amp; !istBuchstabe(Satz[Pos])) Pos++;
    Anfang = Pos;
    while( Pos&lt;Laenge &amp;&amp; !istBuchstabe(Satz[Pos])) Pos++;
    Woerter.push_back( Satz.substr( Anfang, Pos-Anfang ) );
  }
}

long holeAntwort(long WortID)
{
    long min=999999;
    long minID = -1;
    long AntwortID;
    long MaxBindungen=sizeof(Bindungen)/sizeof(Bindungen[0]);
    for (long bi=0; bi&lt;MaxBindungen; ++bi) {
        if (Bindungen[bi].WortID==WortID) {
            AntwortID = Bindungen[bi].AntwortID;
            if (min&gt;Antworten[AntwortID].Aufrufe) {
                minID=AntwortID;
                min=Antworten[AntwortID].Aufrufe;
                --Antworten[AntwortID].Aufrufe;
            }
        }
    }
    return minID;
}

void ersetzePlatzHalter(string &amp;Antwort, const string &amp;Wort)
{
    unsigned long pos = Antwort.find(&quot;$&quot;);
    if (pos!=string::npos) {
        Antwort.replace(pos, 1, Wort);
    }
}

long holePhrase()
{
    long min=999999;
    long minID = -1;
    long MaxPhrasen = sizeof(Phrasen)/sizeof(Phrasen[0]);
    for (long i=0; i&lt;MaxPhrasen; ++i) {
        if (min&gt;Phrasen[i].Aufrufe) {
            minID=i;
            min=Phrasen[i].Aufrufe;
            --Phrasen[i].Aufrufe;
        }
    }
    return minID;
}

void sucheNachAntwort(vector&lt;string&gt; &amp;Woerter, string&amp; Antwort)
{
    long MaxStichwoerter=sizeof(Stichwoerter)
                        /sizeof(Stichwoerter[0]);
    vector&lt;string&gt;::iterator it;
    for (it=Woerter.begin(); it!=Woerter.end(); ++it) {
        for (long wi=0; wi&lt;MaxStichwoerter; ++wi) {
            if (*it == Stichwoerter[wi].Wort) {
                long ID = Stichwoerter[wi].ID;
                long AntwortID = holeAntwort(ID);
                // Nun sollten wir eine ID haben
                if (AntwortID&gt;=0) {
                    Antwort = Antworten[AntwortID].Antwort;
                    ersetzePlatzHalter(Antwort, *it);
                    // Diese Antwort etwas zurückstellen
                    Antworten[AntwortID].Aufrufe+=10;
                    // wir gehen mal einfach
                    return;
                }
            }
        }
    }
    // Kein Stichwort gefunden. Wir faseln...
    long AntwortID = holePhrase();
    Antwort = Phrasen[AntwortID].Antwort;
    // Diese Antwort etwas zurückstellen
    Phrasen[AntwortID].Aufrufe+=10;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009094</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 09:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 09:45:09 GMT]]></title><description><![CDATA[<p>in Klassen.h hast du</p>
<pre><code>using namespace std;
</code></pre>
<p>vergessen<br />
dadurch ist der Typ string unbekannt und deshalb kommen dort die Fehlermeldungen dadurch ist die gesamte Klassendefinition ungültig und die Klassen, die einen string haben, können nicht initialisiert werden.<br />
Also entweder den namespace std benutzen, oder</p>
<pre><code>std::string
</code></pre>
<p>statt</p>
<pre><code>string
</code></pre>
<p>in den Klassendefinitionen schreiben</p>
<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/2009108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009108</guid><dc:creator><![CDATA[Soley]]></dc:creator><pubDate>Thu, 20 Jan 2011 09:45:09 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 09:51:49 GMT]]></title><description><![CDATA[<p>Hab ich jetzt eingefügt. Bekomme jetzt diese Meldung:</p>
<pre><code class="language-cpp">main.cpp: In function ‘int main()’:
main.cpp:13: error: ‘zerlegeInWoerter’ was not declared in this scope
main.cpp:15: error: ‘sucheNachAntwort’ was not declared in this scope
antworten.cpp:8: error: expected ‘}’ before ‘{’ token
antworten.cpp:8: error: expected ‘,’ or ‘;’ before ‘{’ token
antworten.cpp:8: error: expected unqualified-id before ‘,’ token
antworten.cpp:9: error: expected unqualified-id before ‘{’ token
antworten.cpp:9: error: expected unqualified-id before ‘,’ token
antworten.cpp:10: error: expected unqualified-id before ‘{’ token
antworten.cpp:12: error: expected unqualified-id before ‘{’ token
antworten.cpp:13: error: expected unqualified-id before ‘{’ token
antworten.cpp:14: error: expected unqualified-id before ‘{’ token
antworten.cpp:16: error: expected unqualified-id before ‘{’ token
antworten.cpp:17: error: expected declaration before ‘}’ token
phrasen.cpp:7: error: expected ‘}’ before ‘{’ token
phrasen.cpp:7: error: expected ‘,’ or ‘;’ before ‘{’ token
phrasen.cpp:7: error: expected unqualified-id before ‘,’ token
phrasen.cpp:8: error: expected unqualified-id before ‘{’ token
phrasen.cpp:8: error: expected unqualified-id before ‘,’ token
phrasen.cpp:9: error: expected unqualified-id before ‘{’ token
phrasen.cpp:10: error: expected declaration before ‘}’ token
funktionen.cpp: In function ‘long int holeAntwort(long int)’:
funktionen.cpp:33: error: ‘Bindungen’ was not declared in this scope
funktionen.cpp:37: error: ‘Antworten’ was not declared in this scope
funktionen.cpp: In function ‘long int holePhrase()’:
funktionen.cpp:59: error: ‘Phrasen’ was not declared in this scope
funktionen.cpp: In function ‘void sucheNachAntwort(std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::string&amp;)’:
funktionen.cpp:72: error: ‘Stichwoerter’ was not declared in this scope
funktionen.cpp:82: error: ‘Antworten’ was not declared in this scope
funktionen.cpp:94: error: ‘Phrasen’ was not declared in this scope
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009116</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 09:51:49 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 10:03:40 GMT]]></title><description><![CDATA[<p>Nimm niemals using namspace std in Headerdateien. Für Gründe dafür nutze die Forumssuche.<br />
Gibt es eine funktionen.h? Die sollte es zumindest geben und auch in main inkludiert sein. Woher sollte die main deine Funktionen sonst kennen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009121</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 20 Jan 2011 10:03:40 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 10:20:16 GMT]]></title><description><![CDATA[<p>bei antworten.cpp fehlt hinter den geschweiften Klammern in einigen Zeilen jeweils die Kommata. In phrasen.cpp fehlt auch ein Komma nach einer geschweiften Klammer.</p>
<p>Der Poster vor mir hat recht... lieber in Headerfile</p>
<pre><code>std::string
</code></pre>
<p>benutzen und in den .cpp's</p>
<pre><code>using namespace std;
</code></pre>
<p>auf den Namespace wechseln.</p>
<p>Und die anderen Fehler behebst du, indem du die erwähnte Headerdatei für die Funktionen schreibst <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/2009139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009139</guid><dc:creator><![CDATA[Soley]]></dc:creator><pubDate>Thu, 20 Jan 2011 10:20:16 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 10:37:53 GMT]]></title><description><![CDATA[<p>Hab jetzt ales gemacht, was ihr gesagt habt.<br />
Bekomme jetzt aber komischerweise diese Meldung, obwohl die Funktionen deklariert sind:</p>
<pre><code class="language-cpp">main.cpp: In function ‘int main()’:
main.cpp:19: error: ‘zerlegeInWoerter’ was not declared in this scope
main.cpp:21: error: ‘sucheNachAntwort’ was not declared in this scope
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009155</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 10:37:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 10:42:32 GMT]]></title><description><![CDATA[<p>ploib_ schrieb:</p>
<blockquote>
<p>Hab jetzt ales gemacht, was ihr gesagt habt.<br />
Bekomme jetzt aber komischerweise diese Meldung, obwohl die Funktionen deklariert sind:</p>
<pre><code class="language-cpp">main.cpp: In function ‘int main()’:
main.cpp:19: error: ‘zerlegeInWoerter’ was not declared in this scope
main.cpp:21: error: ‘sucheNachAntwort’ was not declared in this scope
</code></pre>
</blockquote>
<p>Wie sieht deine main.cpp aus und die darin eingebundenen Header (abgesehn von Standard-Headern)?<br />
Ohne den aktuellen Stand können wir dir nicht sagen was am aktuellen Stand falsch ist...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009160</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009160</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 20 Jan 2011 10:42:32 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 10:46:06 GMT]]></title><description><![CDATA[<p>Header:</p>
<p>#include &quot;klassen.h&quot;<br />
#include &quot;antworten.h&quot;<br />
#include &quot;bindungen.h&quot;<br />
#include &quot;phrasen.h&quot;<br />
#include &quot;stichwoerter.h&quot;<br />
#include &quot;funktionen.h&quot;</p>
<p>antwort.cpp, bindungen.cpp, phrasen.cpp und stichwoerter.cpp habe ich in .h-Dateien umgeschrieben, sollte man das machen oder nicht??</p>
<p>In funktionen.cpp habe ich auch all diese Header-Dateien eingefügt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009163</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 10:46:06 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 11:03:47 GMT]]></title><description><![CDATA[<p>ploib_ schrieb:</p>
<blockquote>
<p>antwort.cpp, bindungen.cpp, phrasen.cpp und stichwoerter.cpp habe ich in .h-Dateien umgeschrieben, sollte man das machen oder nicht??</p>
</blockquote>
<p>Klares jein. Wenn du Funktionen im Header definierst, bekommst du beim Linken Probleme mit der One Definition Rule (ODR), sobald du den Header mehr als einmal irgendwo einbindest.<br />
Die klassische Lösung ist, die Funktionen im Header nur zu deklarieren und in der .cpp zu definieren, wobei die .cpp den header einbindet (genauso wie deine main.cpp)</p>
<p>Kurzes Beispiel:<br />
f.h:</p>
<pre><code class="language-cpp">//nur Deklaration
void f(int i);
</code></pre>
<p>f.cpp:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &quot;f.h&quot;

void f(int i)
{
  std::cout &lt;&lt; &quot;i: &quot; &lt;&lt; i &lt;&lt; std::endl;
}
</code></pre>
<p>main.cpp:</p>
<pre><code class="language-cpp">#include &quot;f.h&quot;

int main()
{
  for (int i = 1; i &lt; 1000; i *= 2)
  {
    f(i);
  }
}
</code></pre>
<p>Zu deiner Fehlermeldung: Heißt die Funktion im Header auch wirklich so wie du sie in der main() buchstabiert hast? Zeig uns ggf. nochmal deinen kompletten Code, wie er jetzt aussieht - ist ja nicht so viel <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/2009178</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009178</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 20 Jan 2011 11:03:47 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 11:24:31 GMT]]></title><description><![CDATA[<p>main.cpp:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;klassen.h&quot;
#include &quot;antworten.h&quot;
#include &quot;bindungen.h&quot;
#include &quot;phrasen.h&quot;
#include &quot;stichwoerter.h&quot;
#include &quot;funktionen.h&quot;

using namespace std;

int main()
{
    string Aussage;
    while (true) {
        getline(cin, Aussage);
        vector&lt;string&gt; Woerter;
        zerlegeInWoerter(Aussage, Woerter);
        string Antwort;
        sucheNachAntwort(Woerter, Antwort);
        cout &lt;&lt; Antwort &lt;&lt; endl;
    }
}
</code></pre>
<p>klassen.h:</p>
<pre><code class="language-cpp">#ifndef _EKLASSEN_H_
#define _EKLASSEN_H_

#include &lt;string&gt;

class tStichwort {
public:
    std::string Wort;
    int ID;
};

class tAntwort {
public:
    long Aufrufe;
    std::string Antwort;
};

class tBindung {
public:
    long WortID;
    long AntwortID;
};

#endif
</code></pre>
<p>antworten.h:</p>
<pre><code class="language-cpp">#ifndef _EANTWORTEN_H_
#define _EANTWORTEN_H_

#include &quot;klassen.h&quot;

tAntwort Antworten[] = {
{0, &quot;Dein $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deinem $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deinem $!&quot;},
{0, &quot;Deine $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deiner $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deiner $!&quot;},
{0, &quot;$ ist keine echte Lösung.&quot;},
{0, &quot;Es ist nicht gut, mit $ zu leben.&quot;},
{0, &quot;Sollte die Welt nicht auf $ verzichten?&quot;},
{0, &quot;Was bedeutet das eigentlich für Dich: $?&quot;}
                       };

#endif
</code></pre>
<p>bindungen.h:</p>
<pre><code class="language-cpp">#ifndef _EBINDUNGEN_H_
#define _EBINDUNGEN_H_

#include &quot;klassen.h&quot;

tBindung Bindungen[] = {
   {1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}, {2, 5},
   {3, 6}, {3, 7}, {3, 8}, {1, 9}, {2, 9}, {3, 9}
                       };

#endif
</code></pre>
<p>phrasen.h:</p>
<pre><code class="language-cpp">#ifndef _EPHRASEN_H_
#define _EPHRASEN_H_

#include &quot;klassen.h&quot;

tAntwort Phrasen[] = {
    { 0, &quot;Ich verstehe Deine Zurückhaltung.&quot; },
    { 0, &quot;Solltest Du nicht offener von Dir reden?&quot; },
    { 0, &quot;Was meinst Du ist denn die Ursache von all dem?&quot; },
    { 0, &quot;Kannst Du etwas präziser werden?&quot; },
    { 0, &quot;Du solltest nicht alles in Dich hineinfressen.&quot; },
    { 0, &quot;Fühlst Du Dich in dieser Hinsicht unsicher?&quot; }
                       };

#endif
</code></pre>
<p>stichwoerter.h:</p>
<pre><code class="language-cpp">#ifndef _ESTICHWOERTER_H_
#define _ESTICHWOERTER_H_

#include &quot;klassen.h&quot;

tStichwort Stichwoerter[] = {
    {&quot;Bruder&quot;, 1}, {&quot;Vater&quot;, 1}, {&quot;Sohn&quot;, 1}, {&quot;Opa&quot;, 1},
    { &quot;Freund&quot;, 1}, { &quot;Mutter&quot;, 2}, {&quot;Schwester&quot;, 2},
    { &quot;Tochter&quot;, 2}, {&quot;Oma&quot;, 2}, 
    {&quot;Gewalt&quot;, 3}, {&quot;Druck&quot;, 3}, {&quot;Schweigen&quot;, 3}
                 };

#endif
</code></pre>
<p>funktionen.cpp:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;klassen.h&quot;
#include &quot;antworten.h&quot;
#include &quot;bindungen.h&quot;
#include &quot;phrasen.h&quot;
#include &quot;stichwoerter.h&quot;

using namespace std;

bool istBuchstabe(char Zeichen)
{
    if (Zeichen&gt;='a' &amp;&amp; Zeichen&lt;='z') return true;
    if (Zeichen&gt;='A' &amp;&amp; Zeichen&lt;='Z') return true;
    // Mit UTF-8 wird das mit den Umlauten nicht so einfach
    return false;
}

void zerlegeInWoerter(const string &amp;Satz, vector&lt;string&gt; &amp;Woerter)
{
    int Laenge = Satz.length();
    int Pos = 0;
    int Anfang;
    Woerter.clear();
    while (Pos&lt;Laenge) {
        while (Pos&lt;Laenge &amp;&amp; !istBuchstabe(Satz[Pos])) Pos++;
        Anfang = Pos;
        while (Pos&lt;Laenge &amp;&amp; istBuchstabe(Satz[Pos])) Pos++;
        Woerter.push_back(Satz.substr(Anfang, Pos-Anfang));
    }
}

long holeAntwort(long WortID)
{
    long min=999999;
    long minID = -1;
    long AntwortID;
    long MaxBindungen=sizeof(Bindungen)/sizeof(Bindungen[0]);
    for (long bi=0; bi&lt;MaxBindungen; ++bi) {
        if (Bindungen[bi].WortID==WortID) {
            AntwortID = Bindungen[bi].AntwortID;
            if (min&gt;Antworten[AntwortID].Aufrufe) {
                minID=AntwortID;
                min=Antworten[AntwortID].Aufrufe;
                --Antworten[AntwortID].Aufrufe;
            }
        }
    }
    return minID;
}

void ersetzePlatzHalter(string &amp;Antwort, const string &amp;Wort)
{
    unsigned long pos = Antwort.find(&quot;$&quot;);
    if (pos!=string::npos) {
        Antwort.replace(pos, 1, Wort);
    }
}

long holePhrase()
{
    long min=999999;
    long minID = -1;
    long MaxPhrasen = sizeof(Phrasen)/sizeof(Phrasen[0]);
    for (long i=0; i&lt;MaxPhrasen; ++i) {
        if (min&gt;Phrasen[i].Aufrufe) {
            minID=i;
            min=Phrasen[i].Aufrufe;
            --Phrasen[i].Aufrufe;
        }
    }
    return minID;
}

void sucheNachAntwort(vector&lt;string&gt; &amp;Woerter, string&amp; Antwort)
{
    long MaxStichwoerter=sizeof(Stichwoerter)
                        /sizeof(Stichwoerter[0]);
    vector&lt;string&gt;::iterator it;
    for (it=Woerter.begin(); it!=Woerter.end(); ++it) {
        for (long wi=0; wi&lt;MaxStichwoerter; ++wi) {
            if (*it == Stichwoerter[wi].Wort) {
                long ID = Stichwoerter[wi].ID;
                long AntwortID = holeAntwort(ID);
                // Nun sollten wir eine ID haben
                if (AntwortID&gt;=0) {
                    Antwort = Antworten[AntwortID].Antwort;
                    ersetzePlatzHalter(Antwort, *it);
                    // Diese Antwort etwas zurückstellen
                    Antworten[AntwortID].Aufrufe+=10;
                    // wir gehen mal einfach
                    return;
                }
            }
        }
    }
    // Kein Stichwort gefunden. Wir faseln...
    long AntwortID = holePhrase();
    Antwort = Phrasen[AntwortID].Antwort;
    // Diese Antwort etwas zurückstellen
    Phrasen[AntwortID].Aufrufe+=10;
}
</code></pre>
<p>funktionen.h:</p>
<pre><code class="language-cpp">#ifndef _EKLASSEN_H_
#define _EKLASSEN_H_

bool istBuchstabe(char Zeichen);
void zerlegeInWoerter(const string &amp;Satz, vector&lt;string&gt; &amp;Woerter);
long holeAntwort(long WortID);
void ersetzePlatzHalter(string &amp;Antwort, const string &amp;Wort);
long holePhrase();
void sucheNachAntwort(vector&lt;string&gt; &amp;Woerter, string&amp; Antwort);

#endif
</code></pre>
<p>Ja, die Namen der Funktionen sind identisch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009189</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009189</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 11:24:31 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 11:55:44 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Fehler kommentiert</p>
<pre><code class="language-cpp">#ifndef _EKLASSEN_H_ // Includeguards gleich wie bei klassen.h, include wird damit verhindert. Umbenennen!
#define _EKLASSEN_H_

bool istBuchstabe(char Zeichen);
void zerlegeInWoerter(const string &amp;Satz, vector&lt;string&gt; &amp;Woerter); //namespace std:: vor string und vector vergessen
long holeAntwort(long WortID);
void ersetzePlatzHalter(string &amp;Antwort, const string &amp;Wort);
long holePhrase();
void sucheNachAntwort(vector&lt;string&gt; &amp;Woerter, string&amp; Antwort);

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009214</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 20 Jan 2011 11:55:44 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 15:15:20 GMT]]></title><description><![CDATA[<p>Jetzt bekomme ich diese Fehlermeldung:</p>
<pre><code class="language-cpp">/tmp/cccNimqL.o:(.bss+0x0): multiple definition of `Antworten'
/tmp/ccTSoNaF.o:(.bss+0x0): first defined here
/tmp/cccNimqL.o:(.data+0x0): multiple definition of `Bindungen'
/tmp/ccTSoNaF.o:(.data+0x0): first defined here
/tmp/cccNimqL.o:(.bss+0x60): multiple definition of `Phrasen'
/tmp/ccTSoNaF.o:(.bss+0x60): first defined here
/tmp/cccNimqL.o:(.bss+0xa0): multiple definition of `Stichwoerter'
/tmp/ccTSoNaF.o:(.bss+0xa0): first defined here
collect2: ld returned 1 exit status
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2009331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009331</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 15:15:20 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 15:48:56 GMT]]></title><description><![CDATA[<p>Ich habe es jetzt gelöst. Vielen Dank für eure Hilfe.</p>
<p>In der main.cpp mussten die includes</p>
<p>#include &quot;antworten.h&quot;<br />
#include &quot;bindungen.h&quot;<br />
#include &quot;phrasen.h&quot;<br />
#include &quot;stichwoerter.h&quot;</p>
<p>entfernen.<br />
Ich habe jetzt sehr viel dazugelernt. Danke <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/2009356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009356</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 15:48:56 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 15:54:25 GMT]]></title><description><![CDATA[<p>ploib_ schrieb:</p>
<blockquote>
<p>Jetzt bekomme ich diese Fehlermeldung:</p>
<pre><code class="language-cpp">/tmp/cccNimqL.o:(.bss+0x0): multiple definition of `Antworten'
/tmp/ccTSoNaF.o:(.bss+0x0): first defined here
/tmp/cccNimqL.o:(.data+0x0): multiple definition of `Bindungen'
/tmp/ccTSoNaF.o:(.data+0x0): first defined here
/tmp/cccNimqL.o:(.bss+0x60): multiple definition of `Phrasen'
/tmp/ccTSoNaF.o:(.bss+0x60): first defined here
/tmp/cccNimqL.o:(.bss+0xa0): multiple definition of `Stichwoerter'
/tmp/ccTSoNaF.o:(.bss+0xa0): first defined here
collect2: ld returned 1 exit status
</code></pre>
</blockquote>
<p>Das ist genau das was ich oben mit Verletzung der ODR gemeint habe. Die includes aus der Main zu entfernen behebt nur die Symptome, nicht die Ursache (nämlich, dass du die Funktionen non-inline im Header definiert hast).<br />
Schau dir am Besten mal entsprechende Infos zum Arbeiten mit mehreren Übersetzungseinheiten im Buch deiner Wahl oder im Netz an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009358</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 20 Jan 2011 15:54:25 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 16:00:56 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht was ich genau in den Header-Dateien falsch gemacht habe.</p>
<p>z.B.:</p>
<pre><code class="language-cpp">#ifndef _EANTWORTEN_H_
#define _EANTWORTEN_H_

#include &quot;klassen.h&quot;

tAntwort Antworten[] = {
{0, &quot;Dein $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deinem $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deinem $!&quot;},
{0, &quot;Deine $ ist Dir sehr wichtig, nicht wahr?&quot; },
{0, &quot;Hättest Du darüber nicht mit Deiner $ sprechen sollen?&quot;},
{0, &quot;Erzähle mehr über die Beziehung zu Deiner $!&quot;},
{0, &quot;$ ist keine echte Lösung.&quot;},
{0, &quot;Es ist nicht gut, mit $ zu leben.&quot;},
{0, &quot;Sollte die Welt nicht auf $ verzichten?&quot;},
{0, &quot;Was bedeutet das eigentlich für Dich: $?&quot;}
                       };

#endif
</code></pre>
<p>Das ist keine Funktion <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/2009361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009361</guid><dc:creator><![CDATA[ploib_]]></dc:creator><pubDate>Thu, 20 Jan 2011 16:00:56 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Thu, 20 Jan 2011 21:38:20 GMT]]></title><description><![CDATA[<p>ploib_ schrieb:</p>
<blockquote>
<p>Das ist keine Funktion <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>
</blockquote>
<p>Der von dir gepostete Code verletzt die ODR:</p>
<p>ISO/IEC 14882:2003, Abschnitt 3.2 schrieb:</p>
<blockquote>
<p>No translation unit shall contain more than one definition of any variable, function, class type, enumeration type or template.</p>
</blockquote>
<p>Die Variable Antworten wird in jeder Übersetzungseinheit definiert, die die entsprechende Header-Datei inkludiert. Entweder deklarierst du Antworten als const oder verschiebst ihre Definition in eine Übersetzungseinheit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009550</guid><dc:creator><![CDATA[Shlo]]></dc:creator><pubDate>Thu, 20 Jan 2011 21:38:20 GMT</pubDate></item><item><title><![CDATA[Reply to Dateistruktur on Fri, 21 Jan 2011 19:37:05 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<pre><code class="language-cpp">//nur Deklaration
void f(int i);
</code></pre>
</blockquote>
<p>inline vergessen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2009936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2009936</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Fri, 21 Jan 2011 19:37:05 GMT</pubDate></item></channel></rss>