Add every value in stack

Posted by rezivor on Stack Overflow See other posts from Stack Overflow or by rezivor
Published on 2013-10-22T03:50:13Z Indexed on 2013/10/22 3:53 UTC
Read the original article Hit count: 263

Filed under:
|
|

I am trying to figure out a method that will add every value in a stack.

The goal is to use that value to determine if all the values in the stack are even. I have written to code to do this

template <class Object>
bool Stack<Object>::objectIsEven( Object value ) const {
     bool answer = false;
     if (value % 2 == 0)
          answer = true;
     return( answer );
}

However, I am stumped on how to add all of the stack's values in a separate method

© Stack Overflow or respective owner

Related posts about c++

Related posts about stack