Hi friends,
I have 3 different vectors, V1, V2 and V3. V1 and V2 have the same size and each line refers the same record. I would like to write a function that get each line from V3 and check if exists in V2, and if is == "M" in V1.
I tried but I found some errors.
Can you help me?
Cheers,
Sads
V1 V2
M 150
M 152
M 160
M 170
F 190
F 200
M 250
V3
188
160
200
250
string pesqM(vector<string> &V2, vector<string> &V1, vector<string> &V3)
{
for(int a = 0; a < V1.size(); a++)
{
if (V1[a] == "M")
{
cout << "\nPosition: " << a + 1 << endl;
cout << "ID: " << V2[a] << endl;
// Here start the error
vector<string>::iterator it;
iterator to vector element:
it = find(V3.begin(), V3.end(), V2[a]);
cout << "The element is " << *it << endl;
}
}
return ("PM");