stack.h

来自「我学习C++ Primer Plus过程中写下的课后作业的编程代码」· C头文件 代码 · 共 22 行

H
22
字号
// stack.h -- class declaration for the stack ADT
typedef unsigned long Item;

class Stack
{
private:
	enum {MAX = 10};		//constant specific to class
	Item * pitems;			// holds stack items
	int size;				// number of elements in stack
	int top;				// index for top stack item
public:
	Stack(int n = 10);		// crates stack with n elements
	Stack(const Stack & st);
	~Stack();
	bool isempty()const;
	bool isfull()const;
	// push() returns false if stack already is full, true otherwise
	bool push(const Item & item);	// add item to stack
	// pop() returns false if stack already is empty, true otherwise
	bool pop(Item & item);			// pop top into item
	Stack & operator = (const Stack & st);
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?