变量和基本类型

基本内置类型

2.1基本内置类型

2.1.1算术类型

代码日记:

//

#include "stdafx.h"
#include <iostream>
using namespace std;

/*基本内置类型分为算术类型(arithmetic type)和空类型(void)*/
//2.1.1算术类型
void arithmetic_type(void)
{
    /*#算术类型分为#
    *integral type(字符型和布尔型也是整型)和浮点型
    */
    bool bool_example = true;//
    cout << "bool:"<<sizeof(bool)<<"byte "<<bool_example<<endl;
    char char_example = 'a';//字符,8位
    cout << "char:" << sizeof(char) << "byte " << char_example << endl;
    wchar_t wchar_t_example = 'a';//宽字符,至少16位
    cout << "wchar_t" << sizeof(wchar_t) << "byte " << wchar_t_example << endl;
    char16_t char16_t_example = 'a';//最少16位,使用Unicode字符集
    cout << "char16_t:" << sizeof(char16_t) << "byte " << char16_t_example << endl;
    char32_t char32_t_example = 'a';//最少32位,使用Unicode字符集
    cout << "char32_t:" << sizeof(char32_t) << "byte " << char32_t_example << endl;
    short short_example = 10;//最少16位
    cout << "short:" << sizeof(short) << "byte " << short_example << endl;
    int int_example = 10;//至少和short一样大,最小16位
    cout << "int:" << sizeof(int) << "byte " << int_example << endl;
    long long_example = 10;//至少和int一样大,最小32位
    cout << "long:" << sizeof(long) << "byte " << long_example << endl;
    long long long_long_example = 10;//至少和long一样大,最小64位
    cout << "long long:" << sizeof(long long) << "byte " << long_long_example << endl;
    float float_example = 10;//最小尺寸,6位有效数字
    cout << "float:" << sizeof(float) << "byte " << float_example << endl;
    double double_example = 10;//最小尺寸,10位有效数字
    cout << "double:" << sizeof(double) << "byte " << double_example << endl;
    long double long_double_example = 10;//最小尺寸,10位有效数字
    cout << "long double:" << sizeof(long double) << "byte " << long_double_example << endl;
}
//2.1.2类型转换
void type_convert(void)
{
}
int main()
{
    arithmetic_type();
    system("pause");
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值