stack realization with object oriented programming