Is multiple inheritance acceptable for nodes in a tree?
<p>I was wondering:</p>

<p>With a tree, the root can have multiple children and no id. All nodes (except the root) have an id and the leaf nodes can not have children. It is fixed what type must be used for each depth. So the leaves are always of the same type and so are the parents of the leaves.</p>

<p>Since the root and the nodes can have children and only the nodes have an id I was wondering if the following use of multiple inheritance is acceptable:</p>

<pre><code>class NodeWithId
{
    private:
        std::string m_id;
};

template&lt;typename T&gt;
class NodeWithChildren
{
    private:
        std::vector&lt;T&gt; m_nodes;
};

class Network: public NodeWithChildren&lt;Subnet&gt;
{
};

class Subnet: public NodeWithChildren&lt;Machine&gt;, 
                     public NodeWithId
{
};

class Machine: public NodeWithChildren&lt;Application&gt;, 
               public NodeWithId
{
};

class Application: public NodeWithId
{
};
</code></pre>

<p>Or is there a better way to implement this?</p>

<p>edit: </p>

<ul>
<li>removed virtual</li>
<li>changed classnames</li>
</ul>
