Lets say I have a code :
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
    string line,wantedString,newString;
    fstream subor("test.txt");
    while (!subor.fail())  // read line from test.txt
    {
        getline(subor,line);
        line.substr(line.find("?")+1);
        wantedString=line.substr(line.find("?")+1); // will take everything after '?' character till 
'\n'
    }
    cout<<"Enter new text to replace wantedString :";
    getline(cin,newString);
    // how to use string::replace() please ?
    /I tried this but does not work
    getline(subor,line);
    line.replace(wantedString,string::npos,newString); 
    return 0;
}
In test.txt is written only one line :
something?replace 
note: there is no '\n' in the file error thrown by compiler is :
    error: no matching function for call to 'std::__cxx11::basic_string<char>::replace(std::__cxx11::string&, const size_type&, std::__cxx11::string&)'
can you please answer working code with commented explaining why is it like you did it ?
I have studied string::replace() method here: http://www.cplusplus.com/reference/string/string/replace/
Is my logic of using string::find() as a starting point for string to be replaced ?
 
    