Saturday, 15 February 2014

visual c++ - How to pass multiple string parameter in C++ and pass it like an argument? -



visual c++ - How to pass multiple string parameter in C++ and pass it like an argument? -

how pass multiple string parameter in c++ without using vector , pass argument?

i want this.

void myclass::go() { check("string1","string2","string3"); } //guessing void check(string values,...) { //how can output each value here? }

edited: answers, goal pass string paramaters undefine sizes. means don't need input int size. don't want utilize vectors :)

in sentiment best solution utilize vector. way have type safety, , can pass in number of strings.

you can utilize variadic templates.

if know how many strings want pass in, can have parameter list of many strings. pretty tedious though, if alter mind need rewrite function (and every code using it).

the problem var args it's not typesafe, compiler can't verify, want pass in bunch of strings function.

c++ visual-c++ c++builder

No comments:

Post a Comment