When we need to use " &" and when not to?
for example in below, both for loops produce identical result.
std::vector< Product* > itemByColor = pF.by_color( vecProds, Color::Red );
for( auto i : itemByColor )
{
std::cout << " product name <<" << i->name<< std::endl;
}
AND
for( auto& i : itemByColor )
{
std::cout << " product name <<" << i->name<< std::endl;
}
Aucun commentaire:
Enregistrer un commentaire