<?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[Header - Fehler]]></title><description><![CDATA[<p>Irgendwas funzt hier mitm linke nicht? Ich wollte ein externes Objekt erstellen (zur besseren Übersicht), das man dann in der main aufrufen kann.</p>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &quot;game.hpp&quot;
#include &quot;operators.hpp&quot;
#include &quot;story.hpp&quot;
using namespace std;

int main()
{

    wus.set_story(0);

    return 0;
}
</code></pre>
<p>game.hpp</p>
<pre><code class="language-cpp">#ifndef INCLUDE_GAME_HPP
#define INCLUDE_GAME_HPP

#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;limits&gt;

class game
{
    public:

    game();
    ~game();
    struct part
    {
        std::string m_question, m_a, m_b, m_c, m_effect[3];
        part(const std::string&amp; question_,const std::string&amp; a_,const std::string&amp; b_,const std::string&amp; c_,
             const std::string&amp; effect1_,const std::string&amp; effect2_,const std::string&amp; effect3_);
    };
    inline void new_story(const part&amp; data) {m_story.push_back(data);}
    void set_story(size_t index);
    friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, const game::part&amp; data);

    private:
    std::vector&lt;part&gt; m_story;
    const std::string message;

};

#endif // GAME_HPP_INCLUDED
</code></pre>
<p>game.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &quot;game.hpp&quot;

game::game()
:message(&quot;Du bist doch Deutschlands d\x81mmster! Ist es so schwierig eine Zahl zwischen\n1 und 3 einzugeben?&quot;
         + std::string(&quot; Probiers nochmal du Arschloch!\n&quot;))
{

}

game::~game()
{

}

game::part::part(const std::string&amp; question_,const std::string&amp; a_,const std::string&amp; b_,const std::string&amp; c_,
                 const std::string&amp; effect1_,const std::string&amp; effect2_=&quot;&quot;,const std::string&amp; effect3_=&quot;&quot;)
:m_question(question_),m_a(a_),m_b(b_),m_c(c_)
{
    m_effect[0]=effect1_;
    m_effect[1]=effect2_;
    m_effect[2]=effect3_;

}

void game::set_story(size_t index)
{
    std::cout &lt;&lt; m_story[index];
    unsigned short save;
    while(!(std::cin &gt;&gt; save) || (save&gt;3) || (save&lt;1))
    {
        std::cin.clear(); std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
        std::cout &lt;&lt; message;
    }
    if (m_story[index].m_effect[1].empty() == true &amp;&amp; m_story[index].m_effect[2].empty() == true)
    {
        std::cout &lt;&lt; m_story[index].m_effect[0];
        return;
    }
    std::cout &lt;&lt; m_story[index].m_effect[save-1];
}
</code></pre>
<p>operators.hpp</p>
<pre><code class="language-cpp">#ifndef OPERATORS_HPP_INCLUDED
#define OPERATORS_HPP_INCLUDED

#include &lt;iostream&gt;
#include &quot;game.hpp&quot;

std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, const game::part&amp; data);

#endif // OPERATORS_HPP_INCLUDED
</code></pre>
<p>operators.cpp</p>
<pre><code class="language-cpp">#include &quot;operators.hpp&quot;

std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, const game::part&amp; data)
{
    out &lt;&lt; data.m_question &lt;&lt; data.m_a &lt;&lt; data.m_b &lt;&lt; data.m_c;
    return out;
}
</code></pre>
<p>story.hpp [meint ihr das es besser ist wenn ich das in ein story.cpp schreibe? Oder ist das egal ob story.hpp oder story.cpp?]</p>
<pre><code class="language-cpp">#ifndef STORY_HPP_INCLUDED
#define STORY_HPP_INCLUDED

#include &quot;game.hpp&quot;

extern game wus;
wus.new_story(game::part(&quot;Wer wollen sie sein?\n&quot;,
                         &quot;1. Hitler\n&quot;,&quot;2. Gahndi\n&quot;,&quot;3. Georg W. Bush\n&quot;,
                         &quot;Sie sind nun Hitler!\n&quot;, &quot;Sie sind nun Gahndi!\n&quot;, &quot;Sie sind nun Georg W. Bush!\n&quot;));

#endif // STORY_HPP_INCLUDED
</code></pre>
<p>ERRORS:</p>
<blockquote>
<p>-------------- Build: Debug in GAME ---------------<br />
Compiling: main.cpp<br />
In file included from main.cpp:3:<br />
story.hpp:8: error: expected constructor, destructor, or type conversion before '.' token<br />
story.hpp:8: error: expected <code>,' or</code>;' before '.' token<br />
Process terminated with status 1 (0 minutes, 0 seconds)<br />
2 errors, 0 warnings</p>
</blockquote>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/191908/header-fehler</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 06:37:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/191908.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Sep 2007 22:43:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Header - Fehler on Fri, 07 Sep 2007 22:44:07 GMT]]></title><description><![CDATA[<p>Irgendwas funzt hier mitm linke nicht? Ich wollte ein externes Objekt erstellen (zur besseren Übersicht), das man dann in der main aufrufen kann.</p>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &quot;game.hpp&quot;
#include &quot;operators.hpp&quot;
#include &quot;story.hpp&quot;
using namespace std;

int main()
{

    wus.set_story(0);

    return 0;
}
</code></pre>
<p>game.hpp</p>
<pre><code class="language-cpp">#ifndef INCLUDE_GAME_HPP
#define INCLUDE_GAME_HPP

#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;limits&gt;

class game
{
    public:

    game();
    ~game();
    struct part
    {
        std::string m_question, m_a, m_b, m_c, m_effect[3];
        part(const std::string&amp; question_,const std::string&amp; a_,const std::string&amp; b_,const std::string&amp; c_,
             const std::string&amp; effect1_,const std::string&amp; effect2_,const std::string&amp; effect3_);
    };
    inline void new_story(const part&amp; data) {m_story.push_back(data);}
    void set_story(size_t index);
    friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, const game::part&amp; data);

    private:
    std::vector&lt;part&gt; m_story;
    const std::string message;

};

#endif // GAME_HPP_INCLUDED
</code></pre>
<p>game.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &quot;game.hpp&quot;

game::game()
:message(&quot;Du bist doch Deutschlands d\x81mmster! Ist es so schwierig eine Zahl zwischen\n1 und 3 einzugeben?&quot;
         + std::string(&quot; Probiers nochmal du Arschloch!\n&quot;))
{

}

game::~game()
{

}

game::part::part(const std::string&amp; question_,const std::string&amp; a_,const std::string&amp; b_,const std::string&amp; c_,
                 const std::string&amp; effect1_,const std::string&amp; effect2_=&quot;&quot;,const std::string&amp; effect3_=&quot;&quot;)
:m_question(question_),m_a(a_),m_b(b_),m_c(c_)
{
    m_effect[0]=effect1_;
    m_effect[1]=effect2_;
    m_effect[2]=effect3_;

}

void game::set_story(size_t index)
{
    std::cout &lt;&lt; m_story[index];
    unsigned short save;
    while(!(std::cin &gt;&gt; save) || (save&gt;3) || (save&lt;1))
    {
        std::cin.clear(); std::cin.ignore(std::numeric_limits&lt;std::streamsize&gt;::max(), '\n');
        std::cout &lt;&lt; message;
    }
    if (m_story[index].m_effect[1].empty() == true &amp;&amp; m_story[index].m_effect[2].empty() == true)
    {
        std::cout &lt;&lt; m_story[index].m_effect[0];
        return;
    }
    std::cout &lt;&lt; m_story[index].m_effect[save-1];
}
</code></pre>
<p>operators.hpp</p>
<pre><code class="language-cpp">#ifndef OPERATORS_HPP_INCLUDED
#define OPERATORS_HPP_INCLUDED

#include &lt;iostream&gt;
#include &quot;game.hpp&quot;

std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, const game::part&amp; data);

#endif // OPERATORS_HPP_INCLUDED
</code></pre>
<p>operators.cpp</p>
<pre><code class="language-cpp">#include &quot;operators.hpp&quot;

std::ostream&amp; operator&lt;&lt; (std::ostream&amp; out, const game::part&amp; data)
{
    out &lt;&lt; data.m_question &lt;&lt; data.m_a &lt;&lt; data.m_b &lt;&lt; data.m_c;
    return out;
}
</code></pre>
<p>story.hpp [meint ihr das es besser ist wenn ich das in ein story.cpp schreibe? Oder ist das egal ob story.hpp oder story.cpp?]</p>
<pre><code class="language-cpp">#ifndef STORY_HPP_INCLUDED
#define STORY_HPP_INCLUDED

#include &quot;game.hpp&quot;

extern game wus;
wus.new_story(game::part(&quot;Wer wollen sie sein?\n&quot;,
                         &quot;1. Hitler\n&quot;,&quot;2. Gahndi\n&quot;,&quot;3. Georg W. Bush\n&quot;,
                         &quot;Sie sind nun Hitler!\n&quot;, &quot;Sie sind nun Gahndi!\n&quot;, &quot;Sie sind nun Georg W. Bush!\n&quot;));

#endif // STORY_HPP_INCLUDED
</code></pre>
<p>ERRORS:</p>
<blockquote>
<p>-------------- Build: Debug in GAME ---------------<br />
Compiling: main.cpp<br />
In file included from main.cpp:3:<br />
story.hpp:8: error: expected constructor, destructor, or type conversion before '.' token<br />
story.hpp:8: error: expected <code>,' or</code>;' before '.' token<br />
Process terminated with status 1 (0 minutes, 0 seconds)<br />
2 errors, 0 warnings</p>
</blockquote>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361110</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Fri, 07 Sep 2007 22:44:07 GMT</pubDate></item><item><title><![CDATA[Reply to Header - Fehler on Sat, 08 Sep 2007 00:00:34 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>2 kleine Tipps:<br />
a) Globale Variablen sind &quot;böööööööse&quot; (und nur sehr, sehr selten wirklich notwendig bzw. das geringere Übel).<br />
b) mit &quot;extern&quot; erzeugt man noch kein Objekt, sondern weisst nur darauf hin, dass es irgendwo ein (globales) Objekt dieses Names gibt.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361129</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361129</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Sat, 08 Sep 2007 00:00:34 GMT</pubDate></item><item><title><![CDATA[Reply to Header - Fehler on Sat, 08 Sep 2007 00:17:16 GMT]]></title><description><![CDATA[<p>3. Ausserhalb von Funktionen kannst du nicht einfach so Funktionen aufrufen (wus.new_story(...)).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361133</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361133</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 08 Sep 2007 00:17:16 GMT</pubDate></item><item><title><![CDATA[Reply to Header - Fehler on Sat, 08 Sep 2007 00:29:27 GMT]]></title><description><![CDATA[<p>Und was kann ich jetzt machen, wenn ich nicht alle wus.new_story(..) in main.cpp aufrufen möchte? Das wird so nä art text adventure, das ist doch schlechter stil, wenn in der main erst mal 1000 Zeilen Text stehen^^?<br />
Ich will das irgendwo eigens hinschreiben, das es schön sauber aufgeräumt ist....</p>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361135</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sat, 08 Sep 2007 00:29:27 GMT</pubDate></item><item><title><![CDATA[Reply to Header - Fehler on Sat, 08 Sep 2007 03:50:44 GMT]]></title><description><![CDATA[<p>du könntest deiner klasse game noch eine methode run hinzufügen. Dort kannst du deinen ganzen text reinschreiben. dann sieht deine deine main anweisung in etwa so aus</p>
<pre><code class="language-cpp">int main()
{
game.init();
game.run();
game.deinit();

return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1361139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361139</guid><dc:creator><![CDATA[Rontha]]></dc:creator><pubDate>Sat, 08 Sep 2007 03:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to Header - Fehler on Sat, 08 Sep 2007 08:21:08 GMT]]></title><description><![CDATA[<p>Stromberg schrieb:</p>
<blockquote>
<p>Und was kann ich jetzt machen, wenn ich nicht alle wus.new_story(..) in main.cpp aufrufen möchte? Das wird so nä art text adventure, das ist doch schlechter stil, wenn in der main erst mal 1000 Zeilen Text stehen^^?<br />
Ich will das irgendwo eigens hinschreiben, das es schön sauber aufgeräumt ist....</p>
<p>MfG<br />
Stromberg</p>
</blockquote>
<p>Hi,</p>
<p>also wenn Du &quot;1000 Zeilen Text&quot; hast, würde ich den sowieso von File einlesen. Im Source macht Dir das eine &quot;Riesen-Exe&quot; (OK, bei 1000 Zeilen vielleicht noch nicht, kommt aber irgendwann), die jedesmal beim Start in den Speicher geladen werden muss - und von der Du nur 5% aktuell brauchst...<br />
Außerdem macht er den Code unübersichtlich.</p>
<p>(Wenn man die &quot;Einlese-Routine&quot; sparen möchte und sich an der &quot;Riesesexe&quot; nicht stört, kann man den evtl. auch als Stringliteral in einer &quot;.impl&quot;-Datei includen)</p>
<p>Für de &quot;Güte der Programmstruktur&quot; ist es nahezu unerheblich, ob Du 1000 identische Zeilen in main() oder in einer anderen Funktion unterbringst...</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361163</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Sat, 08 Sep 2007 08:21:08 GMT</pubDate></item><item><title><![CDATA[Reply to Header - Fehler on Sat, 08 Sep 2007 09:42:37 GMT]]></title><description><![CDATA[<p>Okay, dann mach ich das mit einer &quot;run&quot; Methode, weil mit .txt Datein und sowas blick ich noch nicht durch.</p>
<pre><code class="language-cpp">void game::run()
{
    new_story(game::part(&quot;Wer wollen sie sein?\n&quot;,
                         &quot;1. Hitler\n&quot;,&quot;2. Gahndi\n&quot;,&quot;3. Georg W. Bush\n&quot;,
                         &quot;Sie sind nun Hitler!\n&quot;, &quot;Sie sind nun Gahndi!\n&quot;, &quot;Sie sind nun Georg W. Bush!\n&quot;));

}
</code></pre>
<p>MfG<br />
Stromberg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1361175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1361175</guid><dc:creator><![CDATA[Stromberg]]></dc:creator><pubDate>Sat, 08 Sep 2007 09:42:37 GMT</pubDate></item></channel></rss>