<?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[Problem bei auslagerung von Klassen in Header]]></title><description><![CDATA[<p>hi,</p>
<p>ich habe versucht einen Code ,in dem die Klassen in der main.cpp waren auszulagern in header Dateien. Dabei ist wohl etwas schief gegangen. Naja seht selbst:</p>
<p>main.cpp:</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Person.h&quot;
#include &quot;Konto.h&quot;

using namespace std;

// -- Programm --
int main(int argc, char *argv[])
{ 
    // neue person
    Person helge(&quot;Helge&quot;,&quot;Maus&quot;);

    // Neues Konto
    Konto kto( helge, 11.73 );

    cout &lt;&lt; &quot;Kontostand: &quot; &lt;&lt; kto.getKontostand() &lt;&lt; endl;
    cout &lt;&lt; &quot;Inhaber: &quot; &lt;&lt; kto.inhaber.getName() &lt;&lt; endl;

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
<p>Person.h</p>
<pre><code class="language-cpp">#include &lt;string&gt;

using namespace std;

class Person
{
      // Eigenschaften
      string vorname;
      string name;

      // Methoden
      public:
             Person(string vorname, string name);

             void setName(string vorname, string name);
             string getName();
};
</code></pre>
<p>Person.cpp:</p>
<pre><code class="language-cpp">#include &quot;Person.h&quot;
#include &lt;string&gt;

using namespace std;

Person::Person(string v, string n) :
                      // init
                      vorname( v ),
                      name( n )
{ }

void Person::setName( string v, string n)
{
    vorname = v; 
    name = n;
}

string Person::getName()
{
       return vorname + &quot; &quot; + name;       
}
</code></pre>
<p>Konto.h:</p>
<pre><code class="language-cpp">#include &lt;string&gt;

using namespace std;

// -- Klasse Konto --

class Konto {
            // Eigenschaften      
            double stand;

            // Methoden
            public:
                   Person inhaber;
                   Konto( Person inh, double std );
                   void setKontostand( double std );
                   double getKontostand(); 
                   string getInhaber();
};
</code></pre>
<p>Konto.cpp</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &quot;Konto.h&quot;
#include &quot;Person.h&quot;

using namespace std;

Konto::Konto( Person inh, double std ) :
              // init
              inhaber( inh ),
              stand (std )
{}

void Konto::setKontostand(double std )
{
  stand = std;                                                    
}

double Konto::getKontostand()
{
       return stand;
}
</code></pre>
<p>Fehlermeldungen:<br />
1.\konto.h(13) : error C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'inhaber'</p>
<p>2.\konto.h(13) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: &quot;default-int&quot; wird von C++ nicht unterstützt.</p>
<p>3.\konto.h(13) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: &quot;default-int&quot; wird von C++ nicht unterstützt.<br />
4.\konto.h(14) : error C2061: Syntaxfehler: Bezeichner 'Person'<br />
5.\konto.cpp(7) : error C2511: 'Konto::Konto(Person,double)': Überladene Memberfunktion nicht in 'Konto' gefunden<br />
6.\konto.h(7): Siehe Deklaration von 'Konto'<br />
7.\konto.cpp(22) : fatal error C1004: Unerwartetes Dateiende gefunden.</p>
<p>Falls euch sonst noch was auffällt oder ihr andere Tipps habt, könnt ihr diese gerne einbringen.</p>
<p>gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/239600/problem-bei-auslagerung-von-klassen-in-header</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 10:58:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/239600.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Apr 2009 14:24:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem bei auslagerung von Klassen in Header on Sat, 25 Apr 2009 14:24:20 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>ich habe versucht einen Code ,in dem die Klassen in der main.cpp waren auszulagern in header Dateien. Dabei ist wohl etwas schief gegangen. Naja seht selbst:</p>
<p>main.cpp:</p>
<pre><code class="language-cpp">#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;Person.h&quot;
#include &quot;Konto.h&quot;

using namespace std;

// -- Programm --
int main(int argc, char *argv[])
{ 
    // neue person
    Person helge(&quot;Helge&quot;,&quot;Maus&quot;);

    // Neues Konto
    Konto kto( helge, 11.73 );

    cout &lt;&lt; &quot;Kontostand: &quot; &lt;&lt; kto.getKontostand() &lt;&lt; endl;
    cout &lt;&lt; &quot;Inhaber: &quot; &lt;&lt; kto.inhaber.getName() &lt;&lt; endl;

    system(&quot;PAUSE&quot;);
    return EXIT_SUCCESS;
}
</code></pre>
<p>Person.h</p>
<pre><code class="language-cpp">#include &lt;string&gt;

using namespace std;

class Person
{
      // Eigenschaften
      string vorname;
      string name;

      // Methoden
      public:
             Person(string vorname, string name);

             void setName(string vorname, string name);
             string getName();
};
</code></pre>
<p>Person.cpp:</p>
<pre><code class="language-cpp">#include &quot;Person.h&quot;
#include &lt;string&gt;

using namespace std;

Person::Person(string v, string n) :
                      // init
                      vorname( v ),
                      name( n )
{ }

void Person::setName( string v, string n)
{
    vorname = v; 
    name = n;
}

string Person::getName()
{
       return vorname + &quot; &quot; + name;       
}
</code></pre>
<p>Konto.h:</p>
<pre><code class="language-cpp">#include &lt;string&gt;

using namespace std;

// -- Klasse Konto --

class Konto {
            // Eigenschaften      
            double stand;

            // Methoden
            public:
                   Person inhaber;
                   Konto( Person inh, double std );
                   void setKontostand( double std );
                   double getKontostand(); 
                   string getInhaber();
};
</code></pre>
<p>Konto.cpp</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &quot;Konto.h&quot;
#include &quot;Person.h&quot;

using namespace std;

Konto::Konto( Person inh, double std ) :
              // init
              inhaber( inh ),
              stand (std )
{}

void Konto::setKontostand(double std )
{
  stand = std;                                                    
}

double Konto::getKontostand()
{
       return stand;
}
</code></pre>
<p>Fehlermeldungen:<br />
1.\konto.h(13) : error C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'inhaber'</p>
<p>2.\konto.h(13) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: &quot;default-int&quot; wird von C++ nicht unterstützt.</p>
<p>3.\konto.h(13) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: &quot;default-int&quot; wird von C++ nicht unterstützt.<br />
4.\konto.h(14) : error C2061: Syntaxfehler: Bezeichner 'Person'<br />
5.\konto.cpp(7) : error C2511: 'Konto::Konto(Person,double)': Überladene Memberfunktion nicht in 'Konto' gefunden<br />
6.\konto.h(7): Siehe Deklaration von 'Konto'<br />
7.\konto.cpp(22) : fatal error C1004: Unerwartetes Dateiende gefunden.</p>
<p>Falls euch sonst noch was auffällt oder ihr andere Tipps habt, könnt ihr diese gerne einbringen.</p>
<p>gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1701153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1701153</guid><dc:creator><![CDATA[cpp~Neuling]]></dc:creator><pubDate>Sat, 25 Apr 2009 14:24:20 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei auslagerung von Klassen in Header on Sat, 25 Apr 2009 14:38:51 GMT]]></title><description><![CDATA[<p>1. Du brauchst Header Guards. Wenn du keine Header Guards machst, wird die Lösung, welche ich dir gleich sage, weitere Fehler bringen.<br />
2. In Konto.h muss ein <code>#include &quot;Person.h&quot;</code> rein, damit dort die Person bekannt ist.</p>
<p>Header Guard:<br />
<a href="http://en.wikipedia.org/wiki/Header_guard" rel="nofollow">http://en.wikipedia.org/wiki/Header_guard</a></p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1701160</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1701160</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 25 Apr 2009 14:38:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei auslagerung von Klassen in Header on Sat, 25 Apr 2009 14:47:17 GMT]]></title><description><![CDATA[<p>Vielen Dank funktioniert jetzt alles. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1701163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1701163</guid><dc:creator><![CDATA[Cpp~Neuling]]></dc:creator><pubDate>Sat, 25 Apr 2009 14:47:17 GMT</pubDate></item></channel></rss>