lundi 24 juillet 2017

error when calling string::insert

[My question is similar to http://ift.tt/2urPGr4= but there is no sample code there, and I didn't find it helpful]

My error is "calling a private constructor of class 'std::__1::__wrap_iter'"

The code is here:

#include <iostream>
#include <string>

using namespace std;

// largestSum()
// returns the largest sum that can be generated 

int main(){
    string g = "this_word";
    cout << g << endl;
    char temp = g[0];
    g.erase(0,1);
    cout << g << endl;
    g.insert(0,temp);
    cout << g << endl;
    return 0;
}

I've tried this through two compilers, and the same error. Read as much as I could from the standard documentation, but don't understand my error.

Aucun commentaire:

Enregistrer un commentaire