Question: C + + 1 . Write a template function, search, that searches a vector for a value, returning the position of the value in the

C++
1. Write a template function, search, that searches a vector for a value, returning the position of the value in the array, or -1 if the value is not found. Be sure to test the function in a program with various data types. The first argument should be the vector, the second argument is the value to search for.
2. Write a template function, copy, with the following declaration:
template
void copy(T arr1[], T arr2[], int n)
The function copies elements from arr2 to arr1. Write a program to test the function with at least the following two arrays:
1) int AInt[6], BInt[6]={1,3,5,7,9,11}
2) struct Student { int field1; double field2; };
Student aStudent[3];
Student BStudent[3]={{1,3.5},{3,0},{5,5.5}};

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 Programming Questions!