// FILE: charstack.cpp // CLASS IMPLEMENTED: CharStack (see charstack.h for documentation) // INVARIANT for the stack class: // 1. The number of chars in the stack is in the member variable used. // 2. The actual chars of the stack are stored in a partially-filled // array data[0]..data[used-1]. The stack elements appear from the // bottom (at data[0]) to the top (at data[used-1]). #include // Provides assert #include "charstack.h" void CharStack::push(const char& entry) // Library facilities used: cassert { assert(size( ) < CAPACITY); data[used] = entry; ++used; } void CharStack::pop( ) // Library facilities used: cassert { assert(!empty( )); --used; } char CharStack::top( ) const // Library facilities used: cassert { assert(!empty( )); return data[used-1]; }