dimanche 22 décembre 2019

decltype not Initializing the Variable Type as Expected

I have a file a.cpp

#include <bits/stdc++.h>

using namespace std;

int main(){
    int a=5;
    double b=4.3;
    decltype(a>b?a:b) n;
    cout << typeid(n).name();   
}

The Output of above Code is : "d" but I expect it to be "i" as "a" is greater than "b"

I am trying to learn about decltype. Can you please tell what I am missing here.

I am using gcc version:

gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)

Aucun commentaire:

Enregistrer un commentaire