[Cs3] return in empty stack
Mikhail Nesterenko
mnestere at kent.edu
Fri Aug 30 12:23:05 EDT 2024
CS3 students,
There was a question about pop() should return if the stack is
empty. The current example does not return anything which generates
compiler warning.
The recommendation is to return an object initialized by a default
constructor. So I updated the code to use our favorite ternary
operator and this default constructor. The original code is commented
out.
http://antares.cs.kent.edu/~mikhail/classes/cs3/Examples/TemplateIntro/Stack/stack.hpp
Thanks,
--
Mikhail
More information about the cs3
mailing list