How to check variant type in C++

 C++ example:

#include <typeinfo>
#include <iostream>
int main() {
int nInt;
char cChar;
std::cout<<"nInt type = " << typeid(nInt).name() <<std::endl;
std::cout<<"cChar type = " << typeid(cChar).name() <<std::endl;
return 0;
}
if you define #include <typeinfo>, you can know type info of the variant.

No comments:

Post a Comment

Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore!

 🏙️ Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore! 🚨 Are you thinking about buying an apartment in 2025? 🏢  It’...