Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <any>
- int main()
- {
- std::any data;
- data = 2;
- data = "Cherno";
- data = std::string("Cherno");
- //Have to know which type it is and then cast it into the type
- //Will throw an exception (bad any cast exception) if the data is not of the type you're casting to
- std::string string = std::any_cast<std::string>(data);
- std::cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement