push_back struct into vector
<pre><code> //prototype    
 void Split(char c, vector &lt;MyString&gt; &amp;outputVector) const           

 //partial code inside split function
 // create new MyString object to push into output vector
 MyString substr;
 substr.mString = newString;
 substr.mLength = size;

 // push new item
 outputVector.push_back(substr);
</code></pre>

<p>After I step over the <code>outputVector.push_back()</code> line, the <code>mString</code> data member is not retained. </p>

<pre><code>//I have two constructors
MyString()
{
    mString = NULL;
    mLength = 0;
}

/*************************************************
 * MyList copy constructor
 * creates a deep copy of a MyString item
 ************************************************/
MyString(const MyString &amp;copy)
{
    mString = new char[copy.mLength];
    int i;

    for(; i &lt; copy.mLength; i++)
    { mString[i] = copy.mString[i]; }

    mString[i] = '\0';
    mLength = copy.mLength;

}
</code></pre>

<p><a href="https://i.stack.imgur.com/PsRaW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PsRaW.png" alt="enter image description here"></a> </p>