c++ - Declare a vector in a function call and pass it by reference -
i'd declare vector
way:
myfunction(new std::vector<stuff>{});
with vector
passed reference:
void myfunction(const std::vector<stuff> &myvec);
you don't need new
argument (which in case returns pointer, not lvalue). can pass temporary:
myfunction(std::vector<stuff>{});
a temporary can bind const
lvalue reference.
Comments
Post a Comment