delete specified names from a list of store names

Hello i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile. I am a beginner and cant figure out a way to do this correctly. Any help is appretiated. Thank you.

1
2
3
4
5
6
7
void Store::deleteSpecifiedStoreFromList(string choice) {
	for (int i = 0; i < this->stores.size(); i++) {
		if(this->stores[i].getStoreNames() == choice) {
			this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
		}
	}
}
Last edited on
You can write the function the following way. Let assume that the vector is defined as std::vector<Store>

1
2
3
4
void Store::deleteSpecifiedStoreFromList(string choice) 
{
	this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), []( const Store &x ) { return ( x.getStoreName() == choice ); } ), this->stores.end() );
}
i get the error "return statement with a value, in function returning 'void' "
Show your updated function code.
never mind i figured it out. thank you.
Topic archived. No new replies allowed.