implementing a stack using inheritance