Should we allocate memory for an object on heap when its internal memory already allocated in heap?
<p>If I use std::vector&lt;> or std::string, do I need to allocate them in heap as well. For example:</p>

<pre><code>int main() {
    std::vector&lt;int&gt;* p = new std::vector&lt;int&gt;();
    delete p;
}
</code></pre>

<p>In Java and C#, objects are always allocated in heap using this syntax. I wonder is it efficient to do the same thing in C++? Because whenever I create a class in C++, I usally mix between stack and heap variables. Let's say:</p>

<pre><code>class simple {
    int a;
    double b;
    std::string c;
    std::vector&lt;int&gt; d;
    ....
};
</code></pre>

<p>I wonder what's the best practice should I follow when using object in C++?</p>

<ul>
<li>All data should be allocated on heap?</li>
<li>All data could be mixed?</li>
<li>or...</li>
</ul>

<p>Thanks,<br>
Chan </p>
