Z
ZikO
Hi
What would you do to return the set of values from a function
1) the list of values
2) a couple values of different types
Something like in LUA:
-- lua code
function f()
-- something to do
return 1, 2, "name";
end
after running
a,b,c = f();
a = 1, b = 2, c = "name".
I know c++ is different than LUA but sometimes I need to get a set of
values from a function. I know there is the pair<T1, T2> type by which I
could have a pair of different values but this is only 2.
I would use one of the containers like the vector, the list or the
deqeue etc. like in example
vector<string> f() {
// something to do
vector<string> list = {"aaa","bbb","ccc"};
return list;
}
But this is not quite efficient Im affraid. Second, vector<> seems to be
difficult to deal with if there's an error and the list can't be generated.
Any suggestions appreciated very much =)
Regards.
What would you do to return the set of values from a function
1) the list of values
2) a couple values of different types
Something like in LUA:
-- lua code
function f()
-- something to do
return 1, 2, "name";
end
after running
a,b,c = f();
a = 1, b = 2, c = "name".
I know c++ is different than LUA but sometimes I need to get a set of
values from a function. I know there is the pair<T1, T2> type by which I
could have a pair of different values but this is only 2.
I would use one of the containers like the vector, the list or the
deqeue etc. like in example
vector<string> f() {
// something to do
vector<string> list = {"aaa","bbb","ccc"};
return list;
}
But this is not quite efficient Im affraid. Second, vector<> seems to be
difficult to deal with if there's an error and the list can't be generated.
Any suggestions appreciated very much =)
Regards.