Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
stack1.cpp
Go to the documentation of this file.
1 
7 // BEGIN_SNIPPET{FullSource}
8 #include "stack1.hpp"
9 #include <iostream>
10 
11 int main()
12 {
13  try {
14  Stack<int> intStack;
15  Stack<std::string> stringStack;
16 
17  intStack.push(7);
18  std::cout << intStack.top() << std::endl;
19 
20  stringStack.push("hello");
21  std::cout << stringStack.top() << std::endl;
22  stringStack.pop();
23  } catch (std::exception const& ex) {
24  std::cerr << "Exception: " << ex.what() << std::endl;
25  return EXIT_FAILURE;
26  }
27  return 0;
28 }
29 // END_SNIPPET{FullSource}
void pop()
Pop element off the stack.
Definition: stack2.hpp:43
Stack class template.
void push(const T &e)
Pushes element onto stack.
Definition: stack1.hpp:52
int main()
Definition: stack1.cpp:11
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
void push(const std::string &s)
Pushes element onto stack.
Definition: stack2.hpp:51
std::string top() const
Return top element of the stack (but not pop-ing it).
Definition: stack2.hpp:53
Specialisation for string as element type.
Definition: stack2.hpp:16