/**
* C++ 数据类型 : https://www.runoob.com/cplusplus/cpp-data-types.html
*
* 布尔: bool
* 字符: char 1 个字节 -128 到 127 或者 0 到 255
* unsigned char 1 个字节 0 到 255
* signed char 1 个字节 -128 到 127
* 整型: int 4个字节 -2147483648 到 2147483647
* unsigned int 4 个字节 0 到 4294967295
* signed int 4个字节 -2147483648 到 2147483647
*
* short int 2 个字节 -32768 到 32767
* unsigned short int 2个字节 0 到 65,535
* signed short int 2个字节 -32768 到 32767
*
* long int 8 个字节 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
* signed long int 8个字节 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
* unsigned long int 8个字节 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
*
* 浮点型: float 4 个字节 精度型占4个字节(32位)内存空间,+/- 3.4e +/- 38 (~7 个数字)
* 双浮点: double 8个字节 双精度型占8 个字节(64位)内存空间,+/- 1.7e +/- 308 (~15 个数字)
* long double 16 个字节 长双精度型 16 个字节(128位)内存空间,可提供18-19位有效数字。
* 无类型: void
* 宽字符: wchar_t 2 或 4 个字节 1 个宽字符 */ #include <iostream>
#include <limits> using namespace std; int main(){
cout << "type: \t\t" << "*******size********" << endl; // endl 换行
// cout << "bool: \t\t" << "所占字节数: " << sizeof(bool) << endl; // sizeof 获取数据类型的大小
// cout << "\t最大值:" << (numeric_limits<bool>::max)(); // (numeric_limits<bool>::max)() 获取数据类型的最大值
// cout << "\t最小值: " << (numeric_limits<bool>::min)() << endl; // (numeric_limits<bool>::max)() 获取数据类型的最小值 // // char
// cout << "char: \t\t" << "所占字节数: " << sizeof(char) << endl; // sizeof 获取数据类型的大小
// cout << "\t最大值:" << (numeric_limits<char>::max)(); // (numeric_limits<bool>::max)() 获取数据类型的最大值
// cout << "\t最小值: " << (numeric_limits<char>::min)() << endl; // (numeric_limits<bool>::max)() 获取数据类型的最小值 // // signed char
// cout << "signed char: \t\t" << "所占字节数: " << sizeof(signed char) << endl; // sizeof 获取数据类型的大小
// cout << "\t最大值:" << (numeric_limits<signed char>::max)(); // (numeric_limits<bool>::max)() 获取数据类型的最大值
// cout << "\t最小值: " << (numeric_limits<signed char>::min)() << endl; // (numeric_limits<bool>::max)() 获取数据类型的最小值 // // unsigned char
// cout << "unisgned char: \t\t" << "所占字节数: " << sizeof(unsigned char) << endl;
// cout << "\t最大值: " << (numeric_limits<unsigned char>::max)();
// cout << "\t最小值: " << (numeric_limits<unsigned char>::min)() << endl; // wchar_t
cout << "wchar_t: \t\t" << "所占字节数: " << sizeof(wchar_t) << endl;
cout << "\t最大值: " << (numeric_limits<wchar_t>::max)();
cout << "\t最小值: " << (numeric_limits<wchar_t>::min)() << endl; // short
cout << "short: \t\t" << "所占字节数: " << sizeof(short) << endl;
cout << "\t最大值: " << (numeric_limits<short>::max)();
cout << "\t最小值: " << (numeric_limits<short>::min)() << endl; // int
cout << "int: \t\t" << "所占字节数: " << sizeof(int) << endl;
cout << "\t最大值: " << (numeric_limits<int>::max)();
cout << "\t最小值: " << (numeric_limits<int>::min)() << endl; // size_t
cout << "size_t: \t\t" << "所占字节数: " << sizeof(size_t) << endl;
cout << "\t最大值: " << (numeric_limits<size_t>::max)();
cout << "\t最小值: " << (numeric_limits<size_t>::min)() << endl; // typedef : 为存在的 类型换个新名字
typedef int number; // typedef 已有类型 新名称;
number age; // 声明 number 类型 的变量 age
age = 18;
// typeid(age).name() 获取变量的数据类型
cout << "age: " << age << "类型: " << typeid(age).name() << endl; // 枚举类型 enum
enum User{
name,
age1
} user;
user = name;
cout << "user: " << user << endl;
return 0;
}

C++:数据类型的更多相关文章

  1. JavaScript 中的数据类型

    Javascript中的数据类型有以下几种情况: 基本类型:string,number,boolean 特殊类型:undefined,null 引用类型:Object,Function,Date,Ar ...

  2. JS 判断数据类型的三种方法

    说到数据类型,我们先理一下JavaScript中常见的几种数据类型: 基本类型:string,number,boolean 特殊类型:undefined,null 引用类型:Object,Functi ...

  3. Python高手之路【二】python基本数据类型

    一:数字 int int(整型): 在32位机器上,整数的位数为32位,取值范围为-2**31-2**31-1,即-2147483648-2147483647 在64位系统上,整数的位数为64位,取值 ...

  4. UniqueIdentifier 数据类型 和 GUID 生成函数

    UniqueIdentifier 数据类型用于存储GUID的值,占用16Byte. SQL Server将UniqueIdentifier存储为16字节的二进制数值,Binary(16),按照特定的格 ...

  5. SQL Server常见数据类型介绍

    数据表是由多个列组成,创建表时必须明确每个列的数据类型,以下列举SQL Server常见数据类型的使用规则,方便查阅. 1.整数类型 int 存储范围是-2,147,483,648到2,147,483 ...

  6. 由js apply与call方法想到的js数据类型(原始类型和引用类型)

    原文地址:由js apply与call方法想到的js数据类型(原始类型和引用类型) js的call方法与apply方法的区别在于第二个参数的不同,他们都有2个参数,第一个为对象(即需要用对象a继承b, ...

  7. python 数据类型 ----字典

    字典由一对key:value 组成的 python中常用且重量级的数据类型 1. key , keys, values 字典由一对key:value 组成的 python中常用且重量级的数据类型 1. ...

  8. SQL数据类型

    1.Character 字符串: 数据类型 描述 存储 char(n) 固定长度的字符串.最多8,000个字符. n varchar(n) 可变长度的字符串.最多8,000个字符.   varchar ...

  9. 跟着老男孩教育学Python开发【第二篇】:Python基本数据类型

    运算符 设定:a=10,b=20 . 算数运算 2.比较运算 3.赋值运算 4.逻辑运算 5.成员运算 基本数据类型 1.数字 int(整型) 在32位机器上,整数的位数为32位,取值范围为-2**3 ...

  10. 我的MYSQL学习心得(二) 数据类型宽度

    我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心得(四) 数据类型 我的MYSQL学习心得(五) 运 ...

随机推荐

  1. Yolov4性能分析(下)

    Yolov4性能分析(下) 六. 权重更新 "darknet/src/detector.c"--train_detector()函数中: ...... /* 开始训练网络 */ f ...

  2. Maven execution terminated abnormally (exit code 1) 完美解决

    https://www.pianshen.com/article/1477185745/ 找到本地仓库这个包中, 删掉,重新导入,,完美解决

  3. Etcd中Raft joint consensus的实现

    Joint consensus 分为2个阶段,first switches to a transitional configuration we call joint consensus; once ...

  4. Qt中的布局浅析与弹簧的使用,以及Qt居中的两种方法

    1. 布局 为什么要布局: 布局之后窗口的排列是有序的 布局之后窗口的大小发生变化, 控件的大小也会对应变化 如果不对控件布局, 窗口显示出来之后有些控件的看不到的 布局是可以嵌套使用 常用的布局方式 ...

  5. centos 7 查看磁盘使用情况

    1.查询系统整体磁盘使用情况 df -h [root@hadoop100 aubunt]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 17 ...

  6. Django(67)drf搜索过滤和排序过滤

    前言 当我们需要对后台的数据进行过滤的时候,drf有两种,搜索过滤和排序过滤. 搜索过滤:比如我们想返回sex=1的,那么我们就可以从所有数据中进行筛选 排序过滤:比如我们想对价格进行升序排列,就可以 ...

  7. 32.qt quick-模仿QQ登录界面实现3D旋转(Rotation、Flipable)

    要想模仿QQ登录界面的3D旋转,我们需要学习Rotation和Flipable.由于没找到QQ的资源图,所以我们以两个图片为例模仿QQ的3D旋转,如下图所示: 最终效果如下所示: 1.Rotation ...

  8. Java synchronized对象级别与类级别的同步锁

    Java synchronized 关键字 可以将一个代码块或一个方法标记为同步代码块.同步代码块是指同一时间只能有一个线程执行的代码,并且执行该代码的线程持有同步锁.synchronized关键字可 ...

  9. 【单调栈】【前缀和】【二分查找】8.28题解-long

    long 题目描述 AP神牛准备给自己盖一座很华丽的宫殿.于是,他看中了一块N*M的矩形空地.空地中每个格子都有自己的海拔高度.AP想让他的宫殿的平均海拔在海平面之上(假设海平面的高度是0,平均数都会 ...

  10. 10、linux启动过程

    (1)linux启动说明: 第一步:开机自检,检查硬件,加载BIOS(帮我们找到启动盘是谁): 第二步:读取MBR(读取启动硬盘0柱面0磁道1扇区(512字节)的前446字节,找到装有操作系统的分区) ...