#pragma once #include template class DopeStack{ static const size_t size = S; T stack[S]; T* head; size_t occupancy; public: DopeStack(); T pop(); void push(T item); T peek(); size_t getOccupancy(){return occupancy;} bool isEmpty(); }; // Implementation ____________________________________________________ template DopeStack::DopeStack(): head (&stack[0]), occupancy(0) { } template T DopeStack::pop(){ T ret = *head; if(head != &stack[0]){ head--; } occupancy--; return ret; } template void DopeStack::push(T item){ if(occupancy != 0){ head++; } *head = item; occupancy++; } template T DopeStack::peek(){ return *head; } template bool DopeStack::isEmpty(){ return (occupancy == 0); }