This answer here uses a *
instead of a &
, so while it is a great read, I am not understanding how it relates to my question.
I am a little confused as to what is going on when I return an std::vector with and without the &.
For example, if my function definition looked like this:
std::vector < foo > & myFunction(...)
{
//myVector is made
return myVector;
}
or this:
std::vector < foo > myFunction(...)
{
//myVector is made
return myVector;
}
The only difference here is there is the first function is returning with &
, and the second one isnt.
My code seems to work in either case, but I am not sure why... what is going on here exactly? Thanks.