I have a set of objects, that need to do something all at once, so I put them all into a vector.However, whenever I try to do something to a specific variable using its original name, nothing happens. When is change the state using the original name, and then access using the vector, the values are different. Why is this?
When a new element is pushed into a vector, the vector obtains a copy of the referenced object. The pushed object is not tied to the original object, which means that any alterations to the pushed object doesn't directly or indirectly alter the original object, hence the reason why the original object remains unaltered.