Hi, in the following code, I am using a pointer to a c++ string in the change() function.
Is there anyway to use the string class' operators when working with a pointer to a string? For example, at() works for the [] operator, but is there any way to use the [] operator?
#include <string>
#include <iostream>
using namespace std;
void change(string * s){
s->at(0) = 't';
s->at(1) = 'w';
// s->[2] = 'o'; does not work
// *s[2] = 'o'; does not work
}
int main(int argc,char ** argv){
string s1 = "one";
change(&s1);
cout << s1 << endl;
return 0;
}