Using Type Deduction with C++ auto keyword, let the compiler deduce the variable type. - C++ Data Type

C++ examples for Data Type:auto

Description

Using Type Deduction with C++ auto keyword, let the compiler deduce the variable type.

Demo Code

#include <iostream>
#include <typeinfo>

using namespace std;

int main()//w ww . jav a 2  s . c  om
{
    auto variable = 1;
    cout << "Type of variable: " << typeid(variable).name() << endl;

    return 0;
}

Result


Related Tutorials