why typeid returns that int and const int are same types

前端 未结 2 1288
不知归路
不知归路 2020-12-06 10:58
if(typeid(int) == typeid(const int))
       cout << \"Same types\"<< endl;

PROGRAM OUTPUT:

Same

2条回答
  •  醉话见心
    2020-12-06 11:17

    You probably want this instead:

    #include 
    
    if (std::is_same::value)
        std::cout << "same types\n";
    else
        std::cout << "different types\n";
    

提交回复
热议问题