SANJU V. S SANJU V. S - 10 months ago 70
C++ Question

Function return different types C++

Which is the best method to use when we need to return different types in a C++ function. Can anybody suggest the best among template, boost variant, union?

Answer Source

In your situation i prefer boost::variant. You can go through the official documentation. Or you can see example illustrated in this blog.