(Solved):Write a template function (in header file) to search a value stored in a vector and return the position (index) of the item if found; otherwise, return a negative value. Then write a driver to test… View Answer…

 

Question

Write a template function (in header file) to search a value stored in a vector and return the position (index) of the item if found; otherwise, return a negative value. Then write a driver to test it. The driver should at least test two different type of vector. Use vector index to do it.

 

EXPERT ANSWER

The template function is implemented as given below.

template < typename T>

int findInVector(const

Scroll to top