You can use the typeid operator:
#include <typeinfo>
...
cout << typeid(variable).name() << endl;
More Related Contents:
- Is it possible to print a variable’s type in standard C++?
- Why does this tell me that "gender" is an undeclared identifier on line
- C++ while loop resetting variables?
- why this unexpected variable change happens? [closed]
- C++ – How to clear variables after a while loop? [closed]
- Why does dividing two int not yield the right value when assigned to double?
- Is it better in C++ to pass by value or pass by constant reference?
- What is a reference variable in C++?
- Pointer vs. Reference
- Why can’t variable names start with numbers?
- Variable initialization in C++
- const vs constexpr on variables
- What is the type of lambda when deduced with “auto” in C++11?
- if (cin >> x) – Why can you use that condition?
- Why do I see strange values when I print uninitialized variables?
- Difference between static, auto, global and local variable in the context of c and c++
- When do function-level static variables get allocated/initialized?
- Is it better in C++ to pass by value or pass by reference-to-const?
- Access variable value using string representing variable’s name in C++ [duplicate]
- What happens to uninitialized variables? C++
- What makes a static variable initialize only once?
- Where do I find the definition of size_t?
- C++ int with preceding 0 changes entire value
- Defining a variable in the condition part of an if-statement?
- c++ warning: address of local variable
- converting a variable name to a string in C++
- generic way to print out variable name in c++
- Static global variables in C++
- Is the comma in a variable list a sequence point?
- Literal initialization for const references