Question: Some short functions: Write a function that returns the intersection of two vectors using the following header. template < typename T> vector intersect( const vector

Some short functions: Write a function that returns the intersection of two vectors using the following header.

template<typename T>

vector intersect(const vector & v1, const vector& v2)

the intersection of two vectors contains the common elements that appear in both vectors.

Here is the test cpp file

#include "Exercise12_31.h"

int main() { //cout << "Enter five strings for vector1: "; string s; vector v1; v1 << "Atlanta" << "Dallas" << "Chicago" << "Boston" << "Denver";

//cout << "Enter five strings for vector2: "; vector v2; v2 << "Dallas" << "Tampa" << "Miami" << "Boston" << "Richmond";

vector v = intersection(v1, v2); cout << "The common strings are "; for (int i = 0; i < v.size(); i++) cout << v[i] << " ";

cout << endl;

system("pause");

return 0; }

submit header and implementation in one header file Exercise12_31.h

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!