#How to initialize a vector as a parameter in a function? c++

9 messages · Page 1 of 1 (latest)

wispy trail
#

i would like to make a new vector just for a function and I don't need to use it elsewhere.
render(std::vector<std::string> vect{ "V","A","G","U","E" } )
The function render takes in a vector<string> parameter. Is it possible to initialize this vector inside the function call? Similar to to_string(14), where 14 is not a variable,

In java, the equivalent is render(new int[] {1,2,3,4})
How would I accomplish this in c++?

spring stoneBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

pastel prism
#

remove the type and keep the things inside {}

safe imp
#

yes you just need to drop the name, and the type should be deducable

wispy trail
#

like this?

#

{ "V","A","G","U","E" }

safe imp
#

yep

wispy trail
#

ok thank yo

#

!solved