Using const_iterator when overloading a const operator[]
<p>I really do not understand what I am doing wrong below. I have a class named Settings with the structure listed below, and two of the functions listed below as well. What I am having trouble with is specifically where to put the const modifiers when overloading a const operator[] within the overloading function. Do I need to use const_cast somewhere? What am I missing?</p>

<pre><code>class Settings
{
    map&lt;string, string&gt; settingsMap;
    map&lt;string, string&gt;::const_iterator itc;

    const string getValue(string) const;

    public:
    const string operator[](string) const;
};

const string Settings::operator[](string K) const
{
    return getValue(K);
}


const string Settings::getValue(const string K) const
{
    const map&lt;string, string&gt; m = settingsMap;
    itc = m.begin();
    while(itc != m.end())
    {
        if(itc-&gt;first==K)
            return itc-&gt;second;
        itc++;
    }
    return 0;
}
</code></pre>

<p>Thanks in advance.</p>
