I got a problem with a iterator. When i compile my project i keep getting this error.
Kitchen.cpp: In member function ‘void Kitchen::If_Cook_Ok(const Order&) const’:
Kitchen.cpp:45:33: error: passing ‘const Order’ as ‘this’ argument of ‘std::list<IngredType::Ingredient> Order::getIngredient()’ discards qualifiers [-fpermissive]
Kitchen.cpp:45:70: error: passing ‘const Order’ as ‘this’ argument of ‘std::list<IngredType::Ingredient> Order::getIngredient()’ discards qualifiers [-fpermissive]
I already tried to put constness on the function member, but i keep getting this error. Here is the code
The Order class has as member variable a std::list witch is returned by the getter getIngredients()
void Kitchen::If_Cook_Ok(const Order &order) const
{
std::cout << "congratulations you barely made it" << std::endl;
std::list<IngredType::Ingredient>::const_iterator it;
for (it = order.getIngredient().begin(); it != order.getIngredient().end(); ++it)
{
std::cout << *it << std::endl;
}
}
Help will be much appreciated.