Defining a class with composition relationship
<p>A document can have many containers and each container may or may not have sub-containers. Each container has name and container id.</p>

<p>In C++ I have modeled it as follows</p>

<pre><code> class Container
    {
        string ContainerName;
        int ContainerID;

        int NumberofSubContainers; //number of sub-containers this contain contains
        Container* subcontainerlist;
    };

    class Document
    {
        string DocumentName;

        int NumofContainers; //number of containers document contains
        Container* containerlist;
    };
</code></pre>

<p>Is this approach correct or can there be a better alternative ?</p>
