Question: I have an object that is apparently double deleted despite being kept track of by smart pointers. I am new to using smart pointers so I made a simple function to test whether I am using the object correctly.

```
int *a = new int(2);

std::shared_ptr<int> b(a);
std::shared_ptr<int> c(a);

```

This set of lines in the main function causes a runtime error as the pointers go out of scope, why? Aren't smart pointers supposed to be able to handle the deletion of a by themselves?

Answer: 
You are only allowd to make a smartpointer once from a raw pointer. All other shared pointers have to be copies of the first one in order for them to work correctly. Even better: use make shared:

```
 std::shared_ptr<int> sp1 = std::make_shared<int>(2);
 std::shared_ptr<int> sp2 = sp1;

```

EDIT: forgot to add the second pointer
Correct usage is:

```
std::shared_ptr<int> b = std::make_shared<int>(2);
std::shared_ptr<int> c = b;

```