Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
stack6.cpp
Go to the documentation of this file.
1 
7 #include "stack6.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.7);
19  floatStack = intStack;
20  std::cout << floatStack.top() << std::endl;
21  floatStack.pop();
22  std::cout << floatStack.top() << std::endl;
23  floatStack.pop();
24  std::cout << floatStack.top() << std::endl;
25  floatStack.pop();
26  } catch (std::exception const& ex) {
27  std::cerr << "Exception: " << ex.what() << std::endl;
28  }
29 
31  vStack.push(42);
32  vStack.push(7);
33  std::cout << vStack.top() << std::endl;
34  vStack.pop();
35 
36  return 0;
37 }
void pop()
Pop element off the stack.
Definition: stack1.hpp:43
int main()
Definition: stack6.cpp:11
void push(const T &e)
Pushes element onto stack.
Definition: stack1.hpp:52
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