If we want to know a variable's type id or compare two variables' type ids are same or not, here is a keyword "typeid" in C++.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int intvar;
long long longlongvar;
bool boolvar;
cout<<"Type name of int: "<<typeid(int).name()<<"\n";
cout<<"Type name of intvar: "<<typeid(intvar).name()<<"\n\n";
cout<<"Type name of long long: "<<typeid(long long).name()<<"\n";
cout<<"Type name of longlongvar: "<<typeid(longlongvar).name()<<"\n\n";
cout<<"Type name of bool: "<<typeid(bool).name()<<"\n";
cout<<"Type name of boolvar: "<<typeid(boolvar).name()<<"\n\n";
return 0;
}
This code shows:
Type name of int: i
Type name of intvar: i
Type name of long long: x
Type name of longlongvar: x
Type name of bool: b
Type name of boolvar: b
"i" for integer, "x" for long long and "b" for bool.
Here are some more type names for other variables.
you can view the code file here : http://ideone.com/XWz3yR
Thanks dipu. Good work :)
dipu_sust How can we implement it in codeforces round? Thanks in advance. :)
Okay, then explore more problems, have more fun! dipu_sust
Good new thing...but I have a question... is it helpful for problem solving specially CF round? Thanks in advance...
It was answered here.
Thank you.