What is "Read Access Violation... was nullptr"?
<p>I could use some help. I have been trying to get my deletion function to work correctly, but no matter what I seem to do it always gives me a "was nullptr" error. My code is a bit messy since I've been panicking and frantically trying anything that comes to mind. I am ready to start over if I need to though. Everywhere I have looked for information about nullptr has not really given an explanation that I actually understand. My understanding is that a "was nullptr" error is given when you try to dereference a pointer/node, but I could never find a way to handle the issue that made sense to me. Any help is really appreciated. My code is:  </p>

<pre><code> `

BT::BT()
{
    node* root = NULL;
}

char BT::FindReplacement(node* parent, char param)
{
    if (parent == NULL) //In case someone tries to delete a node while there aren't any nodes in the Tree
    {
        return NULL;
    } 

    parent = parent-&gt;right;
    while (parent-&gt;left != NULL)
    {
        parent = parent-&gt;left;
    }

    return parent-&gt;data;
}

void BT::leafDriver()
{
    int count = 0;
    leafCount(root, count); 
}

void BT::leafCount(node* start, int count)
{


    if ((start-&gt;left == NULL) &amp;&amp; (start-&gt;right == NULL))
    {
        count++;
    }

    if (start-&gt;left != NULL)
    {
        leafCount(start-&gt;left, count);
    }

    if(start-&gt;right != NULL)
    {
        leafCount(start-&gt;right, count);
    }
cout &lt;&lt; " There are " &lt;&lt; count &lt;&lt; " number of leaves in the BST" &lt;&lt; endl;

}


void BT::deletionDriver(char param)
{
    deletion(root, param);
}

void BT::deletion(node* parent, char param)
{

    if (parent-&gt;data &lt; param) 
    {
        parent-&gt;left = parent-&gt;left-&gt;left;
        deletion(parent -&gt; left, param);
        cout &lt;&lt; "checking left node" &lt;&lt; endl;
    }

    else if (parent-&gt;data &gt; param)
    {
        parent-&gt;right = parent-&gt;right-&gt;right;
        deletion(parent-&gt;right, param);
        cout &lt;&lt; "checking right node" &lt;&lt; endl;
    }

    else if (parent-&gt;data == param)
    {
        //Case 1: No Children
        if (parent-&gt;left == NULL &amp;&amp; parent-&gt;right == NULL)
        {
            delete parent;
            parent = NULL;

        }


        //Case 2: One Child
        else if ((parent-&gt;right == NULL) &amp;&amp; (parent-&gt;left != NULL))
        {
            node* temp = parent;
            parent = parent-&gt;left;
            delete temp;
        }

        else if (parent-&gt;left == NULL)
        {
            node* temp = parent;
            parent - parent-&gt;right;
            delete temp;
        }

        //Case 3: Two Children
        else if ((parent-&gt;left != NULL) &amp;&amp; (parent-&gt;right != NULL))
        {
            char tempParam;
            tempParam = FindReplacement(parent, param);
            parent-&gt;data = tempParam;
            deletion(parent-&gt;right, tempParam);
        }
    }

    else 
        cout &lt;&lt; "Item is not found in BST" &lt;&lt; endl;
}`
</code></pre>