C++编程(2)

Educn int x void f int x x 1 int x x 2 x

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 些方面是由实现确定 的,比如说int 为了保证程序的移植性,建议在所有的可能 之处都使用标准库的功能 提供多种整数类型、无符号类型、浮点类型 的原因是希望使程序员能够利用各种硬件特 性。比方说:不同的硬件对不同的基础类型 处理时,存储的需求、存储访问时间和计算 速度方面存在明显的差异。 Beijing University of Posts & Telecommunications Beijing [email protected] 大小 C++对象大小由char的大小的倍数表示,定义char的大 小为1, 则其他数据类型大小可以用sizeof运算符获得 1=sizeof(char)<=sizeof(short)<=sizeof(int)<=siz eof(long) 1 <= sizeof(bool) <= sizeof(long) sizeof(char) <= sizeof(wchar_t) <= sizeof(long) sizeof(float) <= sizeof(double) <= sizeof(long double) sizeof(N) = sizeof(signed N) = sizeof(unsigned N) Beijing University of Posts & Telecommunications Beijing [email protected] numeric_limits #include <limits> #include <iostream> using namespace std; int main() { cout << "largest float == " << numeric_limits <float> :: max() << ", char is signed == " << numeric_limits&l...
View Full Document

This note was uploaded on 02/10/2014 for the course ECE C++ taught by Professor Xiaoshengtang during the Fall '13 term at BUPT.

Ask a homework question - tutors are online