C++ error, compiler won't recognize string::push_back : <p>The function it has an issue with:</p>

<pre><code>string encode (string message, string key) {

    string code = "whatever";
    string forst;
    int num;
    string::size_type begin = 0;

    message = lower_and_strip(message);

    for (char val : message) {
        num = return_encoded_char(key, begin, val);
        forst = to_string(num);
        code.push_back(forst); //*******************************
    }


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

<p>The starred line is what it points to. The return_encoded_char function returns an integer. </p>

<p>The specific error is 
<code>proj05.cpp:68:23: error: no matching function for call to 'std::basic_string&lt;char&gt;::push_back(std::string&amp;)'</code> and points to the line I starred.</p>

<p>I initially just declared <code>code</code> without initializing it, but changing that didn't fix it. All the similar questions I could find had some other element to blame; I feel like this should be relatively straightforward, though obviously it's not since it isn't working. </p>

<p>I have <code>#include &lt;stream&gt;</code> and <code>using std::to_string</code> etc. I'm using -std=c++11 to compile it.</p>

<p>Help.</p>

<p>P.S. Using Geany on Linux.</p>
