Returning a pointer to a vector element
<p>I'm trying to figure out best way to hold a pointer to an element in a vector that has just been created and added to the member variable vector:</p>

<pre><code>  SceneGraphNode* addChild(std::string name){
    SceneGraphNode child(this,name);
    m_children.push_back(child);
    return &amp;child;
}
</code></pre>

<p>The compiler rightfully gives me a warning since I am returning the address of an object created on the stack, and that object will go out of scope as the function ends. However, the object lives on in the <code>vector</code>, right?</p>

<p>So, should I ignore the warning or is there a better way to do this?</p>
