Recursive data-structures without the use of pointers
<p>During my bachelor degree in CS I've come across the use of recursive data-structures a lot of times. In C++ I always ended up using pointers to make my data structures recursive, just like what I would do in C. </p>

<p>A simplified example could be the following:</p>

<pre><code>struct Tree{
    int data;
    struct Tree *left, *right;
};
</code></pre>

<p>However, using pointers tends to be a risky job and involves a lot hours debugging and testing the code. For these resouns I would like to know if there is any other efficient way of defining recursive data-structures in C++.</p>

<p>In other programming languages, like Rust, I've seen things like that:</p>

<pre><code>struct Node {
    children: Vec&lt;Node&gt;,
    node_type: NodeType,
}
</code></pre>

<p>Is there a safer and confortable way of defining such recursive structures in C++. One possibility would be to use std::Vector, but I am not aware of the performance of the method.</p>