<?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[Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt;]]></title><description><![CDATA[<p>Hallo!<br />
Ich würde gerne eine Map erzeugen, welche den aufbau map&lt;int, eigeneKlasse&gt; hat.<br />
Aber sobald ich sage, dass der Value vom Typ eigeneKlasse ist, gibt es einen Fehler bei der include Anweisung im Header.<br />
undzwar:</p>
<pre><code>In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/map:61:0,
                 from ReisezielEuropa.h:12,
                 from ReisezielEuropa.cpp:10:
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/bits/stl_map.h: In instantiation of 'std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::mapped_type&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator[](const key_type&amp;) [with _Key = int; _Tp = Reisezielinfo; _Compare = std::less&lt;int&gt;; _Alloc = std::allocator&lt;std::pair&lt;const int, Reisezielinfo&gt; &gt;; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::mapped_type = Reisezielinfo; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::key_type = int]':
ReisezielEuropa.cpp:29:26:   required from here
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/bits/stl_map.h:469:59: error: no matching function for call to 'Reisezielinfo::Reisezielinfo()'
           __i = insert(__i, value_type(__k, mapped_type()));
</code></pre>
<p>Ich zeigs einfach mal:<br />
<strong>Header-Datei mit dem Fehler</strong></p>
<pre><code>#ifndef REISEZIELEUROPA_H
#define	REISEZIELEUROPA_H
#include &lt;fstream&gt;
#include &quot;Reisezielinfo.h&quot;
#include &lt;map&gt;

class ReisezielEuropa{
public:
    ReisezielEuropa();
    void addziel(std::string, std::string,std::string,std::string);
    std::map&lt;int, Reisezielinfo&gt;::iterator createStartIterator();
    std::map&lt;int, Reisezielinfo&gt;::iterator createEndIterator();
    virtual ~ReisezielEuropa();
private:
    std::fstream myfile;
    std::map&lt;int,Reisezielinfo&gt; mapeuropa; 
    int counter = 0;
};

#endif	/* REISEZIELEUROPA_H */
</code></pre>
<p><strong>Header-Datei der eigenen Klasse:</strong></p>
<pre><code>#ifndef REISEZIELINFO_H
#define	REISEZIELINFO_H
#include &lt;string&gt;
class Reisezielinfo{
public:
    Reisezielinfo(std::string,std::string, std::string, std::string);
    Reisezielinfo( const Reisezielinfo&amp; orig );
    virtual ~Reisezielinfo();
    std::string GetId() const {return id;}
    std::string GetName() const {return name;}
    std::string GetEinwohner() const {return einwohner;}
    std::string GetLand() const {return land;}
private:
    std::string id,name,land,einwohner;

};

#endif	/* REISEZIELINFO_H */
</code></pre>
<p><strong>Hauptteil der Eigenen Klasse</strong></p>
<pre><code>#include &quot;Reisezielinfo.h&quot;
#include &lt;string&gt;
Reisezielinfo::Reisezielinfo(std::string id,std::string ziel, std::string land, std::string einwohner) {
    this-&gt;id = id;
    name = ziel;
    this-&gt;land = land;
    this-&gt;einwohner = einwohner;
}

Reisezielinfo::Reisezielinfo(const Reisezielinfo&amp; orig) {
}

Reisezielinfo::~Reisezielinfo() {
}
</code></pre>
<p>Sobald ich als Value etwas anderes angebe, funktioniert es...</p>
<p>Ich bin relativ unerfahren in C++ und bin überfordert.<br />
Ich hoffe ihr könnt mir helfen.</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/330783/map-eigene-klasse-als-value-gt-fehler-bei-include-lt-map-gt</link><generator>RSS for Node</generator><lastBuildDate>Thu, 02 Jul 2026 18:23:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/330783.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Jan 2015 12:30:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Sun, 25 Jan 2015 12:31:17 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Ich würde gerne eine Map erzeugen, welche den aufbau map&lt;int, eigeneKlasse&gt; hat.<br />
Aber sobald ich sage, dass der Value vom Typ eigeneKlasse ist, gibt es einen Fehler bei der include Anweisung im Header.<br />
undzwar:</p>
<pre><code>In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/map:61:0,
                 from ReisezielEuropa.h:12,
                 from ReisezielEuropa.cpp:10:
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/bits/stl_map.h: In instantiation of 'std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::mapped_type&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator[](const key_type&amp;) [with _Key = int; _Tp = Reisezielinfo; _Compare = std::less&lt;int&gt;; _Alloc = std::allocator&lt;std::pair&lt;const int, Reisezielinfo&gt; &gt;; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::mapped_type = Reisezielinfo; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::key_type = int]':
ReisezielEuropa.cpp:29:26:   required from here
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/bits/stl_map.h:469:59: error: no matching function for call to 'Reisezielinfo::Reisezielinfo()'
           __i = insert(__i, value_type(__k, mapped_type()));
</code></pre>
<p>Ich zeigs einfach mal:<br />
<strong>Header-Datei mit dem Fehler</strong></p>
<pre><code>#ifndef REISEZIELEUROPA_H
#define	REISEZIELEUROPA_H
#include &lt;fstream&gt;
#include &quot;Reisezielinfo.h&quot;
#include &lt;map&gt;

class ReisezielEuropa{
public:
    ReisezielEuropa();
    void addziel(std::string, std::string,std::string,std::string);
    std::map&lt;int, Reisezielinfo&gt;::iterator createStartIterator();
    std::map&lt;int, Reisezielinfo&gt;::iterator createEndIterator();
    virtual ~ReisezielEuropa();
private:
    std::fstream myfile;
    std::map&lt;int,Reisezielinfo&gt; mapeuropa; 
    int counter = 0;
};

#endif	/* REISEZIELEUROPA_H */
</code></pre>
<p><strong>Header-Datei der eigenen Klasse:</strong></p>
<pre><code>#ifndef REISEZIELINFO_H
#define	REISEZIELINFO_H
#include &lt;string&gt;
class Reisezielinfo{
public:
    Reisezielinfo(std::string,std::string, std::string, std::string);
    Reisezielinfo( const Reisezielinfo&amp; orig );
    virtual ~Reisezielinfo();
    std::string GetId() const {return id;}
    std::string GetName() const {return name;}
    std::string GetEinwohner() const {return einwohner;}
    std::string GetLand() const {return land;}
private:
    std::string id,name,land,einwohner;

};

#endif	/* REISEZIELINFO_H */
</code></pre>
<p><strong>Hauptteil der Eigenen Klasse</strong></p>
<pre><code>#include &quot;Reisezielinfo.h&quot;
#include &lt;string&gt;
Reisezielinfo::Reisezielinfo(std::string id,std::string ziel, std::string land, std::string einwohner) {
    this-&gt;id = id;
    name = ziel;
    this-&gt;land = land;
    this-&gt;einwohner = einwohner;
}

Reisezielinfo::Reisezielinfo(const Reisezielinfo&amp; orig) {
}

Reisezielinfo::~Reisezielinfo() {
}
</code></pre>
<p>Sobald ich als Value etwas anderes angebe, funktioniert es...</p>
<p>Ich bin relativ unerfahren in C++ und bin überfordert.<br />
Ich hoffe ihr könnt mir helfen.</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439603</guid><dc:creator><![CDATA[Eiren]]></dc:creator><pubDate>Sun, 25 Jan 2015 12:31:17 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Sun, 25 Jan 2015 12:40:02 GMT]]></title><description><![CDATA[<p>Dafür brasucvhrt Reise4zielinfo einen Konstruktor ohne Atgumente.<br />
Leider.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439605</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439605</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sun, 25 Jan 2015 12:40:02 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Sun, 25 Jan 2015 12:58:44 GMT]]></title><description><![CDATA[<p>Wenn du den Destruktor ohne Argumente (Defaultkonstruktor) hinzufügst, solltest du den Copykonstruktor (mit const Reisezielinfo&amp; orig) wegwerfen. Deine Klasse funktioniert auch ohne einen selbst geschriebenen, und deiner kopiert nichts.</p>
<p>Mit C++11 kann man auch ohne Defaultkonstruktor auskommen, der Code ist aber hässlich:</p>
<pre><code class="language-cpp">#include &lt;map&gt;
#include &lt;string&gt;

struct a
{
        a( int, std::string ){}
};

int main()
{
        std::map&lt;int,a&gt; m;
        std::string text( &quot;aaa&quot; );
        m.emplace( std::piecewise_construct, std::forward_as_tuple( 1 ),
                std::forward_as_tuple( 1, text ) );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2439608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439608</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 25 Jan 2015 12:58:44 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Sun, 25 Jan 2015 13:07:35 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>brasucvhrt</p>
</blockquote>
<p>Was ist denn da passiert? <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/2439609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439609</guid><dc:creator><![CDATA[Singender Holzkübel]]></dc:creator><pubDate>Sun, 25 Jan 2015 13:07:35 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Sun, 25 Jan 2015 13:11:01 GMT]]></title><description><![CDATA[<p>Die Aussage mit C++11 ziehe ich zurück, es geht auch schön:</p>
<pre><code class="language-cpp">#include &lt;map&gt;
#include &lt;string&gt;

struct a
{
        a( int, std::string ){}
};

int main()
{
        std::map&lt;int,a&gt; m;
        std::string text( &quot;aaa&quot; );
        m.emplace( 1, a{ 1, text } );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2439611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439611</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 25 Jan 2015 13:11:01 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Sun, 25 Jan 2015 14:50:47 GMT]]></title><description><![CDATA[<p>manni666 schrieb:</p>
<blockquote>
<pre><code>m.emplace( std::piecewise_construct, std::forward_as_tuple( 1 ), std::forward_as_tuple( 1, text ) );
</code></pre>
</blockquote>
<p>Klassischer Fall von &quot;Habe keine Ahnung von C++11, einfach mal den Doku-Beispielcode von<a href="https://www.c-plusplus.net/w/cpp/container/map/emplace" rel="nofollow"> <code>emplace_back</code> </a>kopieren und minimal anpassen&quot;. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439628</guid><dc:creator><![CDATA[Kenner der Ahnungslosen]]></dc:creator><pubDate>Sun, 25 Jan 2015 14:50:47 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Mon, 26 Jan 2015 07:24:23 GMT]]></title><description><![CDATA[<p>Hm, also lags an dem nicht vorhandenem Konstruktor...<br />
Komme von Java und da wird der Standart-Konstruktor automatisch erzeugt <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="=/"
      alt="😕"
    /></p>
<p>Naja, vielen Dank für eure Hilfe, jetzt funktioniert ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439768</guid><dc:creator><![CDATA[Eiren]]></dc:creator><pubDate>Mon, 26 Jan 2015 07:24:23 GMT</pubDate></item><item><title><![CDATA[Reply to Map: Eigene Klasse als Value -&amp;gt; Fehler bei #include &amp;lt;map&amp;gt; on Mon, 26 Jan 2015 08:55:53 GMT]]></title><description><![CDATA[<p>Eiren schrieb:</p>
<blockquote>
<p>Hm, also lags an dem nicht vorhandenem Konstruktor...<br />
Komme von Java und da wird der stan****-Konstruktor automatisch erzeugt <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="=/"
      alt="😕"
    /></p>
</blockquote>
<p>Wird er in C++ auch, aber nur, wenn man sonst keinen eigenen Konstruktor definiert hat. Und in Java ist das ebenfalls so. Anders wäre das auch doof, da man ja anscheinend ein Objekt vorliegen hat, das eine bestimmte Art der Konstruktion benötigt. Da wäre es eher ungünstig, wenn dann still und heimlich ein Konstruktor erzeugt würde, der nicht das tut, was man möchte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439782</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 26 Jan 2015 08:55:53 GMT</pubDate></item></channel></rss>