为什么 const 没有显示在 typeid().name() 的输出中,c++
Why const is not shown in the output by typeid().name(), c++
我是c++初学者
#include <iostream>
#include <typeinfo>
int main()
{
const int i = 10;
std::cout << typeid(i).name() << std::endl;
}
i
的类型应该是const int
,但为什么我的笔记本上结果是int
?我正在使用 windows 10, Visual studio IDE.
i
的类型确实是const int
,但是从typeid(i)
返回的std::type_info
对象确实引用了int
;因为 const
被 typeid
.
忽略了
In all cases, cv-qualifiers are ignored by typeid (that is, typeid(T) == typeid(const T)
)
我是c++初学者
#include <iostream>
#include <typeinfo>
int main()
{
const int i = 10;
std::cout << typeid(i).name() << std::endl;
}
i
的类型应该是const int
,但为什么我的笔记本上结果是int
?我正在使用 windows 10, Visual studio IDE.
i
的类型确实是const int
,但是从typeid(i)
返回的std::type_info
对象确实引用了int
;因为 const
被 typeid
.
In all cases, cv-qualifiers are ignored by typeid (that is,
typeid(T) == typeid(const T)
)