数据类型

尽管我们已经谈到了sizeof运算符,我们将再简要的完整性。sizeof操作符返回字节大小,,的类型或变量。

你可以编译并运行下面的程序来找出你有多大的数据类型:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
 
int main()
{
    using namespace std;
    cout << "bool:\t\t" << sizeof(bool) << " bytes" << endl;
    cout << "char:\t\t" << sizeof(char) << " bytes" << endl;
    cout << "wchar_t:\t" << sizeof(wchar_t) << " bytes" << endl;
    cout << "short:\t\t" << sizeof(short) << " bytes" << endl;
    cout << "int:\t\t" << sizeof(int) << " bytes" << endl;
    cout << "long:\t\t" << sizeof(long) << " bytes" << endl;
    cout << "float:\t\t" << sizeof(float) << " bytes" << endl;
    cout << "double:\t\t" << sizeof(double) << " bytes" << endl;
    cout << "long double:\t" << sizeof(long double) << " bytes" << endl;
    return 0;
}
bool:           1 bytes
char:           1 bytes
wchar_t:        2 bytes
short:          2 bytes
int:            4 bytes
long:           4 bytes
float:          4 bytes
double:         8 bytes
long double:    8 bytes

算术运算符(如?:)也被称为有条件的经营者,这是C++的只有三元运算符(需要3个操作数)。的?:操作者提供了一个速记的方法做一个特定类型的if/else语句。

如果别的以下表格报表:

1
2
3
4
if (x > y)
    z = x;
else
    z = y;

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值