efficient way to construct and pass structure of structure as a function parameter
<pre><code>struct StructA
{
    int i;
    int j;
};

// Method 1
struct StructBA
{
    int k;
    StructA sa;
}

// Method 2
struct StructCA
{
    int m;
    StructA *psa;
};

// Method 3
struct StructDA
{
    int n;
    boost::shared_ptr&lt;StructA&gt; psa;
};
</code></pre>

<p>Basically, I need to pass a structure which contains other structures as a function parameter to constructor of a class.
what is the best design practice in this situation?</p>

<p>Note: please correct my understanding if it is incorrect.</p>

<p><strong>My understanding for method 1</strong>>
There is the simplest way to handle the data and we don't need to explicitly allocate resource and release resource.
The only concern is that it may involve unnecessary copies. However, if I always use pass by reference, this should not be a problem.</p>

<p><strong>My understanding for method 2</strong>>
This method has been used extensively in FMOD library (http://www.fmod.org/), so it must have its edge. But we have to manually allocate and release resource.</p>

<p><strong>My understanding for method 3</strong>>
It removes the requirement for manually releasing the allocated resource but it involves overhead compared to method 2.</p>

<p>So which method should I use in practice and when?</p>
