《C++程序设计》(英文版) Chapter 10 Topics

Programming in c++ Simple Data Types: Built-in and Use- Defined Dale/eems/Headington
1 Simple Data Types: Built-in and Use-Defined

Programming in C++ Chapter 10 Topics Built-In Simple Types Integral and Floating Point Data Types Using Combined Assignment Operators Prefix and Postfix Forms of Increment and Decrement Operators Additional C++ Operator Character Sets s Using an Enumeration Type Creating and Including User-Written Header Files
2 Chapter 10 Topics ❖ Built-In Simple Types ❖ Integral and Floating Point Data Types ❖ Using Combined Assignment Operators ❖ Prefix and Postfix Forms of Increment and Decrement Operators ❖ Additional C++ Operator ❖ Character Sets ❖ Using an Enumeration Type ❖ Creating and Including User-Written Header Files

Programming in C++ Built-In Simple Types o Simple(atomic)data type A data type in which each value is atomic(indivisible) 心 Example: a single character of type char is atomic, but the string Good Morning is not
3 Built-In Simple Types ❖Simple(atomic)data type: A data type in which each value is atomic(indivisible). ❖Example: a single character of type char is atomic, but the string “Good Morning” is not

Programming in C++ C++ Simple Data Types simple types ntegral floating char short int long bool enum float double long double unsigned
4 C++ Simple Data Types simple types integral floating char short int long bool enum float double long double unsigned

Programming in C++ By definition the size of a C++ char value is always 1 byte exactly one byte of memory space Sizes of other data type values in C++ are machine-dependent
5 By definition, the size of a C++ char value is always 1 byte. exactly one byte of memory space Sizes of other data type values in C++ are machine-dependent. ‘A’

Programming in C++ Example On one machine, it maybe the case that sizeof(char)=1, sizeof(short)=2 sizeof(int)=4; sizeof(long)=8 On other machine, the size might be as follows sizeof(char)=1, sizeof(short)=2 sizeof(int)=2, sizeof(long)=4
6 Example ❖On one machine,it maybe the case that sizeof(char)=1; sizeof(short)=2; sizeof(int)=4; sizeof(long)=8; ❖On other machine, the size might be as follows: sizeof(char)=1; sizeof(short)=2; sizeof(int)=2; sizeof(long)=4;

Programming in C++ The only guarantees made by C++ are 1= sizeof( char)<= sizeof(short)<= sizeof(int )<= sizeof( long) 1<=sizeof bool)<=sizeof long) sizeof float )< sizeof double )<= sizeof long double) char is at least 8 bits short is at least 16 bits long is at least 32 bits
7 The only guarantees made by C++ are . . . 1 = sizeof( char ) <= sizeof( short ) <= sizeof( int ) <= sizeof( long ) 1 <= sizeof ( bool ) <= sizeof ( long ) sizeof ( float ) <= sizeof ( double ) <= sizeof ( long double ) char is at least 8 bits short is at least 16 bits long is at least 32 bits

Programming in C++ Using one byte(=8 bits ) 01 000 HOW MANY DIFFERENT NUMBERS CAN BE REPRESENTED USING Os and 1s? Each bit can hold either a 0 or a 1. So there are just two choices for each bit. and there are 8 bits 2x2x2x2x2x2x2x2=28=256
8 Using one byte ( = 8 bits ), HOW MANY DIFFERENT NUMBERS CAN BE REPRESENTED USING 0’s and 1’s? Each bit can hold either a 0 or a 1. So there are just two choices for each bit, and there are 8 bits. 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 = 28 = 256 0 1 1 0 0 0 1 1

Programming in C++ Similarly, using two bytes(=16 bits) 0110001 0100 1010 16 65536 DIFFERENT NUMBERS CAN BE REPRESENTED If we wish to have only one number representing the integer zero, and half of the remaining numbers positive, and half negative, we can obtain the 65, 536 numbers in the range below -32,768 0 32767
9 Similarly, using two bytes ( = 16 bits), 2 16 = 65,536 DIFFERENT NUMBERS CAN BE REPRESENTED. If we wish to have only one number representing the integer zero, and half of the remaining numbers positive, and half negative, we can obtain the 65,536 numbers in the range below : -32,768 . . . . 0 . . . . 32,767 0 1 1 0 0 0 1 1 0 1 0 0 1 0 1 0

Programming in C++ Range of Values The interval within which values of a numeric type must fall, specified in terms of the largest and smallest allowable values 10
10 Range of Values The interval within which values of a numeric type must fall,specified in terms of the largest and smallest allowable values
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《C++程序设计》(英文版) Chapter 9 Topics.ppt
- 《C++程序设计》(英文版) Chapter 8 Topics.ppt
- 《C++程序设计》(英文版) Chapter 7 Topics.ppt
- 《C++程序设计》(英文版) Chapter 6 Topics.ppt
- 《C++程序设计》(英文版) Chapter 5 Topics.ppt
- 《C++程序设计》(英文版) Chapter 4 Topics.ppt
- 《C++程序设计》(英文版) Chapter 3 Topics.ppt
- 《C++程序设计》(英文版) Chapter 2 Topics.ppt
- 《C++程序设计》(英文版) Chapter 1 Topics.ppt
- 《网络互连技术教程》第9章 广播.ppt
- 《网络互连技术教程》第8章 用户数据报协议—UDP.ppt
- 《网络互连技术教程》第7章 CMP和网络状态.ppt
- 《网络互连技术教程》第6章 地址解析.ppt
- 《网络互连技术教程》第5章 子网与超网.ppt
- 《网络互连技术教程》第4章 网络互连协议——IP.ppt
- 《网络互连技术教程》第3章 网络接入技术.ppt
- 《网络互连技术教程》第2章 网络互连体系.ppt
- 《网络互连技术教程》第1章 网络的历史与发展.ppt
- 《网络互连技术教程》第12章 应用服务.ppt
- 《网络互连技术教程》第11章 域名服务系统—DNS.ppt
- 《C++程序设计》(英文版) Chapter 11 Topics.ppt
- 《C++程序设计》(英文版) Chapter 12 Topic.ppt
- 《C++程序设计》(英文版) Chapter 13 Topics.ppt
- 《C++程序设计》(英文版) Chapter 14 Topics.ppt
- 《C++程序设计》(英文版) Chapter 15 Topics.ppt
- 《Java编程技术基础》第一章 面向对象原理与实现.ppt
- 《Java编程技术基础》第二章 Java的实现基础.ppt
- 《Java编程技术基础》第二章习题.doc
- 《Java编程技术基础》第三章 类与对象(一).ppt
- 《Java编程技术基础》第三章习题.doc
- 《Java编程技术基础》第四章 类与对象(二).ppt
- 《Java编程技术基础》第四章习题.doc
- 《Java编程技术基础》第五章 异常与垃圾收集.ppt
- 《Java编程技术基础》第五章习题.doc
- 《Java编程技术基础》第十一章 Java集合框架.ppt
- 《Java编程技术基础》第十一章习题.doc
- 《Java编程技术基础》第二章 JDBC.ppt
- 武汉外语外事职业学院:《VisualBasic语言程序设计教程》第二版 第14章 图形处理.ppt
- 武汉外语外事职业学院:《VisualBasic语言程序设计教程》第二版 第3章 窗体.ppt
- 武汉外语外事职业学院:《VisualBasic语言程序设计教程》第二版 第5章 Visual Basic语法基础.ppt