Why not just have a function for each type of widget you want to create, with the appropriate number of parameters? You can then use the wrapper function directly, and internally call your other code with the correct data (although I wouldn't keep that interface personally).
That is exactly what i am trying to evade.
I got same code for each case... I could have one base function that has 6 lines of code, and all other functions could call it, but it gets to spaghetti code unneedly.
If there is one string passed or 100 string passed, the function is still 6 lines of code. i hate to make allot of functions that take different amount of string parameter and then call the 6 base lines of code, i find it just waste.
Possibly i didn't understand what you meant.
If you just want to pass many strings to function and you are using C++11, the easiest approach is to use initializer list.
void func(std::vector<std::string> const &_vs);
int main()
{
func({"one", "two", "three"});
return 0;
}
I already tried that out
void func(std::vector<std::string> const vS)
{
std::cout<<vS[0]<<std::endl;
}
int main()
{
func({"Hello", "Hy"});
compiler error
Ignore that its on 84 line, its the func() call made.
1>c:\c++\projects\test\test\main.cpp(84): error C2143: syntax error : missing ')' before '{'
1>c:\c++\projects\test\test\main.cpp(84): error C2660: 'func' : function does not take 0 arguments
1>c:\c++\projects\test\test\main.cpp(84): error C2143: syntax error : missing ';' before '{'
1>c:\c++\projects\test\test\main.cpp(84): error C2143: syntax error : missing ';' before '}'
1>c:\c++\projects\test\test\main.cpp(84): error C2059: syntax error : ')'
Possible i don't have latest c++11?
I have c++11 function as
for(int & i : vecOfInt)
{...}