+ 1

How can i know the type of an variable in c++

20th Feb 2018, 3:30 PM
Amit Bhandari
Amit Bhandari - avatar
6 Answers
0
i dont know
20th Feb 2018, 3:30 PM
Amit Bhandari
Amit Bhandari - avatar
0
decltype(variable) gives you the type for the name you must do some meta programming
20th Feb 2018, 3:34 PM
---
--- - avatar
0
what is meta programming actually
20th Feb 2018, 3:35 PM
Amit Bhandari
Amit Bhandari - avatar
0
wikipedia is your friend!
20th Feb 2018, 3:53 PM
---
--- - avatar
0
#include <typeinfo> ... cout << typeid(variable).name() << endl; typeid is a C++ language operator which returns type identification information at run time. Check this code : https://code.sololearn.com/cxq1Zcg3uykB/#cpp
20th Feb 2018, 3:58 PM
J Domingo Jiménez J
J Domingo Jiménez J - avatar
0
typeid(...).name is not working in generall and not working for your own classes, you can only achieve it properly by writing some template stuff. e.g. specialize a template function where you return the name.
20th Feb 2018, 4:10 PM
---
--- - avatar