/* Professor Scott, stack.cpp 2/15/24 Example of data hiding to implement a simple stack data structure */ #include #include using namespace std; template class MyStack { public: void Add(T const &); // add an element to queue void Remove(); // remove an element to queue void Print(); // display elements in queue private: std::deque data; // is this good style? why not? }; template void MyStack ::Add(T const &d) { data.push_back(d); // add to the back of vector } template void MyStack::Remove() { data.pop_back(); } template void MyStack::Print() { // display contents of vector using iterators for (int i = data.size()-1; i >= 0; i--) cout << " " << data[i] << endl; } //Usage for C++ class templates int main() { MyStack s; // define a queue s.Add(1); // add two values to queue s.Add(2); cout<<"Before removing data"<