Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

Find the time Mercury takes to orbit the sun.

Answered: 1 week ago

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago