user2381422
user2381422

Reputation: 5805

auto reference to a vector in c++

I have an auto reference to a vector:

auto &myVector = solution->myVector;

where solution->myVector is a public member, a vector of some objects.

If I later do this in the code:

myVector = someOtherVector;

will solution->myVector change?

Thanks

Upvotes: 0

Views: 165

Answers (2)

slaphappy
slaphappy

Reputation: 6999

Yes. This will call myVector.operator=() which is, in fact, solution->myVector.operator=().

Upvotes: 3

blue
blue

Reputation: 2793

Yes of course, as it would happen if the public member was an int.

Upvotes: 1

Related Questions