C++ has references for such problems
Code:
#include <iostream>
#include <string>
using namespace std;
void create(string *& x)
{
cout << "adr x before: " << x << endl; // not initialized
x= new string("aaa");
cout << "adr x after: " << x << endl;
}
int main()
{
string *s = 0; // a pointer to a string ( as in your description )
cout << "adr s bevore: " << s << endl; // was initialized to 0
create(s);
cout << "adr s after: " << s << " = " << *s << endl;
delete s; // dont forget about this
return 0;
}
Kurt
EDIT: too late, but look at it as a variation of vart's solution