<?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[[gelöst] hash_map Deklaration]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe hier ein Problem beim erstellen einer Klasse, die eine hash_map benutzt.<br />
Ich erhalte ua die Fehlermeldung:</p>
<p>Fehler: ISO-C++ verbietet Deklaration von »hash_map« ohne Typ Huffman2 Encoder.hpp line 24 1255776849564 585</p>
<pre><code class="language-cpp">/* 
 * File:   Encoder.hpp
 * Author: anna
 *
 * Created on 11. Oktober 2009, 20:49
 */

#include &lt;map&gt;
#include &lt;hash_map&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;list&gt;
#include &lt;string&gt;

#include &quot;TreeNode.hpp&quot;

using namespace std;

class Encoder {
private:
    fstream file;
    hash_map&lt;unsigned char, unsigned int&gt; freq_map;
    list&lt;TreeNode&gt; NodeList;

public:

    Encoder(fstream f) {
        file = f;
        createFrequencyMap();
    }

    Encoder(){

    }

private:

    void createFrequencyMap() {

        // file.open( s.c_str(), fstream::in );
        char ctmp = file.get();

        while (ctmp != EOF) {
            cout &lt;&lt; ctmp &lt;&lt; &quot;\n&quot;;
            freq_map[ctmp]++;
            // _totalCharCount++;

            ctmp = file.get();

        }
    }

    // Bitcode fehlt
    void createTree() {
        for (hash_map::iterator iter = freq_map.begin(); wfi != freq_map.end(); ++wfi) {
            TreeNode temp(freq_map-&gt;first, freq_map-&gt;second);
            NodeList.push_front(tempconst char *);
        }
        // Man darf gespannt sein
        while (NodeList.size() != 1) {
            NodeList.sort();
            TreeNode smallest = NodeList.pop_front();
            TreeNode ndsmallest = NodeList.pop_front();
            NodeList.push_front(TreeNode connection(smallest, ndsmallest, smallest.getFrequency() + 2ndsmallest.getFrequency()));
        }
    }

}; /* _ENCODER_HPP */
</code></pre>
<p>Ich nutze g++4.3.3</p>
<p>Kann mir jemand erkären, was denn da noch rein muss?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/252271/gelöst-hash_map-deklaration</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 19:28:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252271.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Oct 2009 11:07:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [gelöst] hash_map Deklaration on Sat, 17 Oct 2009 22:27:39 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe hier ein Problem beim erstellen einer Klasse, die eine hash_map benutzt.<br />
Ich erhalte ua die Fehlermeldung:</p>
<p>Fehler: ISO-C++ verbietet Deklaration von »hash_map« ohne Typ Huffman2 Encoder.hpp line 24 1255776849564 585</p>
<pre><code class="language-cpp">/* 
 * File:   Encoder.hpp
 * Author: anna
 *
 * Created on 11. Oktober 2009, 20:49
 */

#include &lt;map&gt;
#include &lt;hash_map&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;list&gt;
#include &lt;string&gt;

#include &quot;TreeNode.hpp&quot;

using namespace std;

class Encoder {
private:
    fstream file;
    hash_map&lt;unsigned char, unsigned int&gt; freq_map;
    list&lt;TreeNode&gt; NodeList;

public:

    Encoder(fstream f) {
        file = f;
        createFrequencyMap();
    }

    Encoder(){

    }

private:

    void createFrequencyMap() {

        // file.open( s.c_str(), fstream::in );
        char ctmp = file.get();

        while (ctmp != EOF) {
            cout &lt;&lt; ctmp &lt;&lt; &quot;\n&quot;;
            freq_map[ctmp]++;
            // _totalCharCount++;

            ctmp = file.get();

        }
    }

    // Bitcode fehlt
    void createTree() {
        for (hash_map::iterator iter = freq_map.begin(); wfi != freq_map.end(); ++wfi) {
            TreeNode temp(freq_map-&gt;first, freq_map-&gt;second);
            NodeList.push_front(tempconst char *);
        }
        // Man darf gespannt sein
        while (NodeList.size() != 1) {
            NodeList.sort();
            TreeNode smallest = NodeList.pop_front();
            TreeNode ndsmallest = NodeList.pop_front();
            NodeList.push_front(TreeNode connection(smallest, ndsmallest, smallest.getFrequency() + 2ndsmallest.getFrequency()));
        }
    }

}; /* _ENCODER_HPP */
</code></pre>
<p>Ich nutze g++4.3.3</p>
<p>Kann mir jemand erkären, was denn da noch rein muss?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1793738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1793738</guid><dc:creator><![CDATA[Anna++ 0]]></dc:creator><pubDate>Sat, 17 Oct 2009 22:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] hash_map Deklaration on Sat, 17 Oct 2009 11:45:45 GMT]]></title><description><![CDATA[<p>Bist du sicher, daß der Fehler schon in Zeile 24 auftritt und nicht erst in Zeile 59? Da fehlen nämlich die Template-Parameter:</p>
<pre><code class="language-cpp">hash_map&lt;unsigned char, unsigned int&gt;::iterator iter = ...
</code></pre>
<p>Du kannst dir stattdessen auch ein typedef definieren:</p>
<pre><code class="language-cpp">typedef hash_map&lt;unsigned char, unsigned int&gt; MyHashMap;

MyHashMap::iterator iter = ...;
</code></pre>
<p>P.S. &quot;using namespace std;&quot; in Header-Dateien ist böse!<br />
Und trenne besser Deklaration und Definition in .h und .cpp-Datei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1793762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1793762</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sat, 17 Oct 2009 11:45:45 GMT</pubDate></item><item><title><![CDATA[Reply to [gelöst] hash_map Deklaration on Sat, 17 Oct 2009 16:16:39 GMT]]></title><description><![CDATA[<p>Ich bin einfach auf ein reines map umgestiegen, dann geht es.</p>
<p>Ich hab übrigens noch ne .cpp Datei, das war nur die Klasse, um die es ging.</p>
<p>Trotzdem danke für die Antwort!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1793884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1793884</guid><dc:creator><![CDATA[Anna++ 0]]></dc:creator><pubDate>Sat, 17 Oct 2009 16:16:39 GMT</pubDate></item></channel></rss>