return values from function

I want to return two arrays from a function. How can I achieve this?
Thank you~
One of these, perhaps:
1
2
3
4
5
std::pair< std::vector<int>, std::vector<double> > foo() ;

std::vector<int> bar( std::vector<double>& result2 ) ;

void baz( std::vector<int>& result1, std::vector<double>& result2 ) ;

I cannot understand the last two, can you explain them? thanks!
> I cannot understand the last two, can you explain them?

std::vector<int> bar( std::vector<double>& result2 ) ;
returns a vector<int> and sets the values in the vector<bouble> which is passed by reference.

In void baz( std::vector<int>& result1, std::vector<double>& result2 ) ;, both sequences are passed by reference.

See: http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/

Last edited on
We could give a better answer if you were more specific about what you are trying to do, exactly. Can you post some code that demonstrates what you want? (The code doesn't have to work, obviously -- it just has to show us what you are trying to do.)
Topic archived. No new replies allowed.