PDA

View Full Version : سوال: مشکل برنامه زیر چیه؟



fakhradin
یک شنبه 12 اردیبهشت 1389, 21:59 عصر
#include <cstdlib>
#include <iostream>
using namespace std;
template <class type>class linklist;
template <class type>class node
{
friend class linklist<type>;
private:
type data;
node<type>* link;
public:
node():link(NULL) {}
node(type a):data(a),link(NULL) {}
};
template <class type>class linklist
{
private:
node<type>* first;
public:
linklist();
void insert(const type &,int);
void show();
~linklist() { delete first; }
};
template <class type>linklist<type>::linklist()
{
first=new node<type>;
first=NULL;
}
template <class type>
void linklist<type>::insert(const type &a,int n=1)
{
node<type>* temp=new node<type>;
temp->data=a;
//if(n<0) { cout<<"not"<<endl; return; }
/*else*/ if(!first || n==1) { temp->link=first; first=temp; }
else if(n>1)
{
node<type> *b=new node<type>;
b=first;
for(;--n;b=b->link) {}
temp->link=b->link;
b->link=temp;
}
}
template <class type>void linklist<type>::show()
{
for(node<type>* q=first;q;q=q->link)
cout<<q->data<<endl;
}
int main(int argc, char *argv[])
{
linklist<int> l;
//l.insert(5,1);
l.insert(4,1);
l.insert(7,3);
l.show();
linklist<float> l1;
system("PAUSE");
return EXIT_SUCCESS;
}

من این برنامه را در محیط dev-cpp امتحان کردم و ارور زیر را می دهد لطفا در این مورد من را راهنمایی کنید؟
file:///C:/Documents%20and%20Settings/ITC3/Desktop/untitled.bmp

(file:///C:/Documents%20and%20Settings/ITC3/Desktop/untitled.bmp)