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

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -