Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

check if an item is in a vector c++

bool Movies::add_movie(std::string name, std::string rating, int watched) {
    Movie pass(name,rating,watched);
    for(int i{0}; i < movies.size(); i++){
        if(movies.at(i).get_name() == name){
            return false;
        }
    }
    movies.push_back(pass);
    return true;
}
 
PREVIOUS NEXT
Tagged: #check #item #vector
ADD COMMENT
Topic
Name
9+5 =