Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class Item>
- class Stack
- {
- struct Element
- {
- double inf;
- Element *next;
- Element(double x, Element *p) : inf(x), next(p)
- {
- }
- };
- Element *head;
- public:
- Stack() :head(0)
- {
- }
- bool Empty()
- {
- return head == 0;
- }
- double Pop()
- {
- if (Empty())
- {
- return 0;
- }
- Element *r = head;
- double i = r->inf;
- head = r->next;
- delete r;
- return i;
- }
- void Push(double data)
- {
- head = new Element(data, head);
- }
- double Top()
- {
- if (Empty())
- {
- return 0;
- }
- else
- {
- return head->inf;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement