Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
stack7.cpp
Go to the documentation of this file.
1 
7 #include "stack7.hpp"
8 #include <iostream>
9 #include <vector>
10 
11 int main()
12 {
13  try {
14  Stack<int> intStack;
15  Stack<float> floatStack;
16  intStack.push(42);
17  intStack.push(7);
18  floatStack.push(7.7F);
19  std::cout << floatStack.top() << std::endl;
20  floatStack.pop();
21  std::cout << floatStack.top() << std::endl;
22  floatStack.pop();
23  std::cout << floatStack.top() << std::endl;
24  floatStack.pop();
25  } catch (std::exception const& ex) {
26  std::cerr << "Exception: " << ex.what() << std::endl;
27  }
28 
29  Stack<int, std::allocator<int>, std::vector> vStack;
30  vStack.push(42);
31  vStack.push(7);
32  std::cout << vStack.top() << std::endl;
33  vStack.pop();
34 
35  return 0;
36 }
void pop()
Pop element off the stack.
Definition: stack1.hpp:43
int main()
Definition: stack7.cpp:11
void push(const T &e)
Pushes element onto stack.
Definition: stack1.hpp:52
Demonstrate use of member function templates.
Stack class using vector as element container.
Definition: stack1.hpp:15
T top() const
Return top element of the stack (but not pop-ing it).
Definition: stack1.hpp:58