栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++如何判断变量类型

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++如何判断变量类型

C++如何判断变量类型

使用 typeid 判断其类型:(需要在编译语言选项中选择 RTTI 编译选项),例子:【引用自这里】,详情可以看这里

#include 
#include 
using namespace std;
int main()
{
	char *p=NULL;
	char str[]="hello world";
	cout< 

打印出的类型并不是可以直接读懂的,可以参考下面的类型对照表【参考自这里】解读。

   ::= v	# void
		 						::= w	# wchar_t
		 						::= b	# bool
		 						::= c	# char
		 						::= a	# signed char
		 						::= h	# unsigned char
		 						::= s	# short
		 						::= t	# unsigned short
		 						::= i	# int
		 						::= j	# unsigned int
		 						::= l	# long
		 						::= m	# unsigned long
		 						::= x	# long long, __int64
		 						::= y	# unsigned long long, __int64
		 						::= n	# __int128
		 						::= o	# unsigned __int128
		 						::= f	# float
		 						::= d	# double
		 						::= e	# long double, __float80
		 						::= g	# __float128
		 						::= z	# ellipsis
                 				::= Dd # IEEE 754r decimal floating point (64 bits)
                 				::= De # IEEE 754r decimal floating point (128 bits)
                 				::= Df # IEEE 754r decimal floating point (32 bits)
                 				::= Dh # IEEE 754r half-precision floating point (16 bits)
                 				::= DF  _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
                 				::= DB  _        # C23 signed _BitInt(N)
                 				::= DB  _ # C23 signed _BitInt(N)
                 				::= DU  _        # C23 unsigned _BitInt(N)
                 				::= DU  _ # C23 unsigned _BitInt(N)
                 				::= Di # char32_t
                 				::= Ds # char16_t
                 				::= Du # char8_t
                 				::= Da # auto
                 				::= Dc # decltype(auto)
                 				::= Dn # std::nullptr_t (i.e., decltype(nullptr))
		 						::= u  [] # vendor extended type
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/997721.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号