template<class t> void simplelist<t>::in_node_l(void){ node* fin; fin=new node; (*last).next=fin; last=fin; size++; }
i segmentation fault(core dumped) error when in_node_l member function called function push
template<class t> void stack<t>::push(t var){ simplelist<t>::in_node_l(); (*(this->last)).data=var; position++; return; }
stack derived class :
class stack : public simplelist<t>
node declared as
template<class t> struct simplelist<t>::node{ t data; node* next; };
if call in_node_l in main not errors.
the constructor class stack is:
template<class t> stack<t>::stack(int s,string n) :simplelist<t>(s,n) { position=1; }
constructor simplelist given by
template<class t> simplelist<t>::simplelist(int s,string n){ int i; //name= input name node *prev,*current; size=s; name=n; if(s==1){ current=new node; first=current; last=current; cout<<"simplelist constructur"<<endl; } else{ (i=1;i<s;i++){ current=new node; if(i==1){ first=current; } else{ (*prev).next=current; if(i==s-1){ last=current; if(last=(*prev).next){ cout<<"simplelist constructur2"<<endl; } } } prev=current; } }
}
Comments
Post a Comment