📄 stack.h
字号:
#ifndef STACK_H
#define STACK_H
class node{
public:
unsigned char c;
node* next;
node(char cc,node* n=NULL){c=cc;next=n;}
node(node* n=NULL){next=n;}
};
class stack:public node{
private:
node* head;
int length;
public:
stack(){head=NULL;length = 0;}
~stack()
{
node* temp;
while(head!=NULL)
{
temp=head;
head=head->next;
delete head;
}
}
void push(const unsigned char& cc)
{
node* temp;
temp=head;
head=new node(cc,temp);
++length;
}
bool pop(unsigned char& cc)
{
if(head==NULL)
return false;
node* temp;
temp=head;
head=head->next;
cc=temp->c;
delete temp;
--length;
return true;
}
int getLength()
{
return length;
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -