?? lstack1.h
字號:
#ifndef LSTACK1_H
#define LSTACK1_H
#include "link3.h"
template<class Elem>class LStack1
{
private:
int size;
public:
LStack1(){top=NULL;size=0;}
~LStack1(){clear();}
void clear()
{
while(top!=NULL)
{
Link<Elem>* temp=top;
top=top->next;
size=0;
delete temp;
}
}
bool push(const Elem& item)
{
top=new Link<Elem>(item,top);
size++;
return true;
}
bool pop(Elem& it)
{
if(size==0)return false;
it=top->element;
Link<Elem>* ltemp=top->next;
delete top;
top=ltemp;
size--;
return true;
}
bool topValue(Elem& it)const
{
if(size==0)return false;
it=top->element;
return true;
}
bool play()
{ int tempsize=size;
Link<Elem>* temptop=top;
while(tempsize!=0)
{ tempsize--;
cout<<temptop->element<<" ";
temptop=temptop->next;
}
return false;
}
int length()const {return size;}
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -