Home / utk / cs140 / sp19 / live_codings_in_lab / part1_concepts / stack_templated / main.cpp
Directory Listing
main.cpp
stack.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
#include "stack.hpp"

using namespace std;

struct tyler {
	string name;
	int id;

	friend ostream &operator<<(ostream&, const tyler&);
};

//Tell the ostream class that it's ok to access the tyler class
ostream &operator<<(ostream& out, const tyler& obj) {
	out << "{" << obj.name << ", " << obj.id << "}";

	return out;
}

int main() {
	//Easter egg for a student in the lab at the time
	tyler senter;

	//Make a stack that accepts the "tyler" class.
	cn_stack<tyler> obj;

	//Setup the instance, then push
	senter.id = 0;
	senter.name = "pi";
	obj.push(senter);

	//Ditto
	senter.id = 1;
	senter.name = "raspberry";
	obj.push(senter);

	//Print
	obj.debug_print();

	//Clean up
	obj.clear();
}