Creating a singly linked list with an x and y minimum and maximum range in C++
<p>I'm trying to create a linked list using a minimum and maximum value. This may be a really stupid way of doing this, and maybe I should be using a vector to accomplish what I want to do.</p>

<p>I'm having a really hard time inserting, I have no idea why this is not working, I have poured the internet, looked in my books, but nothing is getting this to work. Maybe it's because I am using smart pointers and I am not 100% confident with using them yet but here is my Node:</p>

<pre><code>struct Node
{
    Node(int m = 0, int M = 0, std::shared_ptr&lt;Node&gt; r = nullptr) : min(m), max(M), right(r){}
    std::shared_ptr&lt;Node&gt; right;

    int min;
    int max;
};
</code></pre>

<p>I believe this is set up correctly, but here is my insert Function, and I am certain this is the problem. And I am not sure if this should be a void function, or if it should be a std::shared_ptr</p>

<pre><code>std::shared_ptr&lt;Node&gt; Container::insert(std::shared_ptr&lt;Node&gt; list, int min, int max) 
{

    if(!list)
    {
        list = std::make_shared&lt;Node&gt;(min, max);
    }

    list-&gt;right = insert(list-&gt;right, min, max);
    return list;

}
</code></pre>

<p>I'm kind of at a lost here, and maybe I'm just not understanding the problem well enough. Basically, I just want to be able to compare minimums and maximums. Again, it just might be a really bad way that I am approaching the problem.</p>