why does code 1 gives segfault error whereas code 2 doesn't, both are basically same, do anyone have any suggestion?

1.

```
#include <iostream>
using namespace std;
template <class T>
class nodes
{
template <class U> friend class linklistchain;
private:
nodes<T> *adrs;
T data;
};
template <class T>
class linklistchain
{
private:
nodes<T> *first,*last;
public:
linklistchain();
~linklistchain();
bool isEmpty();
bool insert(const T &x);
};
template <class T>
linklistchain<T>::linklistchain(){
last = NULL;
}
template <class T>
linklistchain<T>::~linklistchain(){
delete last;
}
template <class T>
bool linklistchain<T>::isEmpty(){
if (last)
{
return true;
}
else
{
return false;
}
}
template <class T>
bool linklistchain<T>::insert(const T &x)
{
isEmpty();
cout <<"ending insert";
return true;
}
int main()
{
linklistchain<int> *pr1;
cout<<"started";
pr1->insert(5);
return 0;
}
```

2.

```
#include <iostream>
using namespace std;
int main ()
{
int *ptr = NULL;
cout << "The value of ptr is " << ptr <<"\n";
if(ptr) cout<<"ptr\n";
if(!ptr) cout<<"not ptr\n";
return 0;
}
```