How to resolve `no viable overloaded operator[] for type 'std::map<AudioTypes, const char *>`?
<p>So I followed this <a href="https://stackoverflow.com/a/24296298/1983337" title="SO link">SO answer</a> for my purposes, and I really do not know how to resolve this error. When I try to access <code>audioType[wav]</code> or <code>audioType[mp3]</code>, the error below comes up. Looking up the internet was not helpful for me.</p>

<p><code>error: no viable overloaded operator[] for type 'const std::map&lt;AudioTypes, const char *&gt;</code></p>

<p><code>note: candidate function not viable: 'this' argument has type 'const
      std::map&lt;AudioTypes, const char *&gt;', but method is not marked const
    mapped_type&amp; operator[](const key_type&amp; __k);</code></p>

<pre><code>// WAVFile.h
class WAVFile {
    // ...
    private:
        enum AudioTypes: int;
        static std::map&lt;AudioTypes, const char*&gt; audioType;
    // ...
}

// WAVFile.cpp
enum AudioTypes: int {
    wav,
    mp3
};

static map&lt;AudioTypes, const char*&gt; audioType = {
    {wav, "wav"},
    {mp3, "mp3"}
};

bool WAVFile::exportAudio(const char* filename, const char* filetype) {
    // temporary test code    
    cout &lt;&lt; audioType[wav] &lt;&lt; endl;
    return true;
}

// main.cpp
int main() {
    file.exportAudio("export_i ran.wav","wav") ? cout &lt;&lt; "Exported\n" : cout &lt;&lt; "Failed\n";

    return 0;
}
</code></pre>