stack.h

来自「rsa加密算法的vc实现」· C头文件 代码 · 共 52 行

H
52
字号
#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 + =
减小字号Ctrl + -
显示快捷键?