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>>' to 'std::_Deque_iterator>>' Project1 c:\users\lafol\downloads\skeleton (1)\stack.hpp 92

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::iterator itr = _container.begin(); itr != _container.end(); ++itr) { if (*itr == target) return position; else position++; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!