0

Compare of two different Data type

I want know that can we compare the data type of variables in an expression. If possible how?

2nd May 2019, 5:51 AM
unknown
unknown - avatar
9 odpowiedzi
+ 5
unknown Have you figured it out? So I tried finding that question (I slightly remember being similar), but I can't find it anymore, I didn't bookmark the thread either unfortunately. But I found some links, might be helpful, there is the easy way and there's also the bit more complex way, but since you wanted this, it shouldn't be a problem. [Easy way] http://www.cplusplus.com/reference/typeinfo/ [Not so easy way] https://stackoverflow.com/questions/19773453/ask-a-variable-what-data-type-it-is-in-c https://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c I still don't understand why you want to check variable type though, since C++ is statically typed language - you know already what type something is as you declare it in code.
3rd May 2019, 3:41 AM
Ipang
+ 3
Then you shouldn't have that many languages specification in Relevant Tags unknown .
2nd May 2019, 6:33 AM
Ipang
+ 2
if (typeof a == typeof b)
2nd May 2019, 5:55 AM
Gordon
Gordon - avatar
+ 2
Ok Ipang . Do you have the answer for this?
2nd May 2019, 8:15 AM
unknown
unknown - avatar
+ 2
unknown What exactly did you mean by comparing data type in expression? you want to check if the variables' type are all the same or what? I remember slightly a question asking how to check for a variable's type, but that is not comparing the data type. Elaborate some more on this thought will you?
2nd May 2019, 12:27 PM
Ipang
+ 2
Yes i want to check the data type of the two variables, weather they are same or not? Ipang
2nd May 2019, 4:26 PM
unknown
unknown - avatar
+ 2
Thank you Ipang
3rd May 2019, 5:12 AM
unknown
unknown - avatar
+ 2
You're welcome, anyways, will you share with me what is it you're trying to code? I'm curious, maybe share that code you're currently working on unknown
3rd May 2019, 5:48 AM
Ipang
0
I want in c++
2nd May 2019, 6:13 AM
unknown
unknown - avatar