Return class pointer from a function
<p>I am not sure what is wrong with this (keep in mind I'm kinda sorta new to C++)</p>

<p>I have this class:</p>

<pre><code>Foo
{
  string name;
  public:
     SetName(string);
}
string Foo::SetName(string name)
{
  this-&gt;name = name;
  return this-&gt;name;
};
//////////////////////////////////////////////
//This  is where I am trying to return a Foo pointer from this global function:

Foo * ReturnFooPointer()
{
  Foo foo;
  Foo * foo_ptr;
  foo_ptr = &amp;foo;
  return foo_ptr;
}
</code></pre>

<p>At compile time, this compiles just fine. However at run time it throws a runtime exception(Some sort of access violation)</p>

<p>What am I doing wrong?</p>
