Category: boost::any
boost::any usage details
What is boost::any : boost::any is a class from Boost::any Library. It provides the ability to store arbitrary information in a variable in C++. Advertisements What to include : Header File – “boost/any.hpp”. Frequently Asked: boost::any usage details boost::any questions What can be stored in boost::any : Anything that is copy constructable like, Built-in data …
boost::any questions
Question 1: Will this code compile : Advertisements #include <iostream> #include “boost/any.hpp” class Node { private: int value; Node(const Node & obj) { value = obj.value; } public: Node(int i) { value = i; } }; int main() { boost::any var1 = new Node(5); return 0; } Answer: [code collapse=”true”] Yes, because we are storing …