Source:
Passing references to pointers in C++
Q: How do I pass a reference of pointer to a function?
void func(string*& val) {
//...
}
{
string s;
func(&s);
}this doesn't comile.
cannot convert parameter 1 from 'std::string *' to 'std::string *&'
A:
You need an actual string pointer instead of an anonymous string pointer.
string s;
string * ptr_s = &s;
func(ptr_s);should work.