Thursday 5 May 2011

Handling Multiple Return values in JAVA (C++ aswell :-)

After lot of Goggling and reading the best solution i could find for this problem was at http://javatuples.com/. The tuples implementation provides us utilities for handling scenarios where we would need to return multiple return types from a Java function (Basically its a kind of Wrapper implementation for the return objects). A similar implementation can be used in C++ by developing a template class to hold multiple types of data and return that class object, but C++ gives us total flexibility to use pointers hence we can achieve it even with out an additional Class implementation.

I'm still a newbie so people pour in your suggestions if there are better ways to achieve the same.

No comments:

Post a Comment