Using auto with Uniform Initialization - C++ Data Type

C++ examples for Data Type:auto

Description

Using auto with Uniform Initialization

Demo Code

#include <iostream>
#include <typeinfo>

using namespace std;

class MyClass/*ww  w . j a va 2  s.  c o  m*/
{
};

int main()
{
    auto variable{ 1 };
    cout << "Type of variable: " << typeid(variable).name() << endl;
    auto variable2{ MyClass{} };
    cout << "Type of variable: " << typeid(variable2).name() << endl;

    return 0;
}

Result


Related Tutorials