Any datatype in C++ boost library
C++ also provides this functionality but only with the help of boost library. Any type of value can be assigned to a variable by just making its datatype any. Below is the required syntax for declaring a variable with any datatype:
Note: To use the boost::any datatype, “boost/any.hpp” needs to be included in the program.
boost::any x, y, z, a; x = 12; y = 'G'; z = string("GeeksForGeeks"); a = 12.75;
12 G GeeksForGeeks 12.75 Exception Caught : boost::bad_any_cast: failed conversion using boost::any_cast