Confusing myself with too many pointers to pointers
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6711041/c-passing-pointer-variable-to-function">C++: Passing pointer variable to function</a>  </p>
</blockquote>



<p>Here is a simplified code snippet which I think shows the problem at hand:</p>

<pre><code>std::wstring *Variable3 = &amp;SomeWStringObject;

int _tmain(int argc, _TCHAR* argv[])
{
    std::wstring *Variable1 = NULL;
    func(Variable1);
}

void func(std::wstring *Variable2)
{
    Variable2 = Variable3;
}
</code></pre>

<p>Now, in reality, <code>func</code> is a member of a class, and <code>Variable3</code> is also a member of that same class. For this simpler example, let's just assume that <code>Variable3</code> is some sort of global variable.</p>

<p><code>Variable3</code> is a (global variable) pointer to a <code>std::wstring</code> object. I can see in the debugger than it is pointing to the correct string.</p>

<p>What I want to end up with is <code>Variable1</code> pointing to the same std::wstring object as <code>Variable3</code>. </p>

<p>So I tried passing the address of pointer <code>Variable1</code> into the function, which I hoped would then set the address <code>Variable3</code> points to into <code>Variable1</code>.</p>

<p>But this isn't working. It seems to be set OK, but then when the program leaves <code>func</code>, Variable1 is still a null pointer.</p>

<p>I have tried to be as clear as I can. I hope it is enough. Unfortunately, I cannot use the return value of func for this, as I actually have two other <code>std::wstringstream</code> objects to do the same thing to. Since all are having the same problem, I simplified it down to just one <code>std::wstring</code> object. I have tried lots of other different combinations of <code>&amp;</code> and <code>*</code>, but none have worked.</p>

<p>Thank you very much for any help you can offer. </p>
