模板单链表,运行后就非法退出!解决方法

模板单链表,运行后就非法退出!
在实例化时失败了?编译成功的~
SingleLinkList.cpp内容如下:

#include <iostream>
using namespace std;

//#ifndef SINGLE_LINK_LIST_H
//#define SINGLE_LINK_LIST_H
template <class T>
class SLNode;
//.......................................
template <class T>
class LinkedNode
{
friend SLNode<T>;
private:
T data;
LinkedNode<T> *next;
};//.....................................

template <class T>
class SLNode
{
public:
SLNode();
~SLNode();
bool isEmpty() const {return head->next == NULL;}
int getLength() const;
void output(ostream& out) const;
void createLinkNode();
private:
LinkedNode<T> *head;
};
//#endif
//............................................................the proportion of implement........................................//
template <class T>
SLNode<T>::~SLNode()
{
LinkedNode<T> *next;
while (head->next)
{
next = head->next;
head->next = next->next;
delete next;
}
}
//...............................................................................................................................................................//
template <class T>
int SLNode<T>::getLength() const
{
  LinkedNode<T> *cur = head->next;
  int len = 0;
while (cur)
{
len ++;
cur = cur->next;
}
return len;
}
//...............................................................................................................................................................//
template <class T>
void SLNode<T>::output(ostream& out) const
{
LinkedNode<T> * cur = head->next;
int count = 1;
while (cur)
{
out << cur->data << " ";
cur = cur->next;
if (count % 10 == 0)
out << endl;
}
}
//...............................................................................................................................................................//
template <class T>
void SLNode<T>::createLinkNode()
{
cout << "How many nodes do you want to create: ";
int count = 0, i = 0;
cin >> count;
cout << "Input " << count << "elements :" << endl;
  LinkedNode<T>*cur = head;
  while (i < count)
{
LinkedNode<T> *newNode = new LinkedNode<T>;
cin >> newNode->data;
newNode->next = NULL;
cur->next = newNode;
cur = newNode;
i ++;
}
}
//...............................................................................................................................................................//
template <class T>
SLNode<T>::SLNode()
{
head->next= NULL;
}



main.cpp内容如下:
#include <iostream>
using namespace std;
#include "SingleLinkList.cpp"

int main()
{
SLNode<int> sList;
sList.createLinkNode();
cout << "The length of the single link is:" << sList.getLength() << endl;
cout << "The elements of the single link are:" << endl;
sList.output(cout);

return 0;
}

------解决方案--------------------
template <class T>
SLNode<T>::SLNode()
{
head = new LinkedNode<T>();//<-------------------------初始化
head->next= NULL;
}
------解决方案--------------------
很高兴回答你的问题!楼上正解,因为你的head指针没有new,没有开辟空间。