lundi 27 janvier 2020

Comparing 2 vectors and removing elements from 2nd vector that are not found in the 1st - c++

I have 2 string vectors:

vector < string > animals = {"cat", "dog", "pig", "tiger", "monkey", "lion"}
vector < string > someAnimals = {"dog", "mouse", "snake", "monkey", "cat"}

How can I compare these 2 vectors and remove elements in someAnimals vector("mouse" and "snake") that aren't found in the animals Vector?

Aucun commentaire:

Enregistrer un commentaire