+ 1
How can i know the type of an variable in c++
6 Answers
0
i dont know
0
decltype(variable) gives you the type
for the name you must do some meta programming
0
what is meta programming actually
0
wikipedia is your friend!
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
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.