I have a problem to write code / function that will check that number which provides user belongs to std::stack
or not. I tried making it in different ways but I haven't found any working solutions.
I tried:
std::stack<int> myStack;
const bool isInStack = myStack.find(userNumber) != myStack.end();
I tried also:
std::stack<int> myStack;
if (myStack.count(userNumber)) {
// x is in the set, count is 1
} else {
// count zero, i.e. x not in the set
}
I tried also to write own template but I couldn't and it also wasn't working. I don't have any idea how can I make it working.
I get errors like class std::stack<int, std::deque<int, std::allocator<int>>>" has no member "find"
Can anyone help me? I'm really getting annoyed with it.