Question: I am trying to code a search function in C++ using deque from the C++ library and I'm having trouble implementing the search function. For
I am trying to code a search function in C++ using deque from the C++ library and I'm having trouble implementing the search function.
For some reason when I run the following code I get this error: Error C2440 'initializing': cannot convert from 'std::_Deque_const_iterator
How can/should I modify this code to correct this error.
// Returns the 1-based position where an object is on this stack. // If the object target occurs as an item in this stack, this function // returns the distance from the top of the stack of the occurrence // nearest the top of the stack; the topmost item on the stack is // considered to be at distance 1. The overloaded == function is used to // compare target to the items in this stack. int search(const T& target = T{}) const { int position = 1; for (std::deque
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
