I passed a std::vector object to a function that searched for a particular element and then deleted it. After much trouble, I realized c++ doesn't work the way I thought it did, and needed to add & to the functions signature. Why?
Say you declare
technically speaking is first an object, or pointer to an object? I assumed it was a pointer to an object and that's why even if c++ is pass by value then then when the function is called, the value (i.e. address) of the object is still the same.Code:std::vector<int> first;