You are on page 1of 26

Chapter 16

Data representation
Jack Dong
16.01 user-defined data types
• Data type
Data types
• Integer
• String
• Boolean
• Real(float)
• Date
• Currency
Non-composite data type
Without reference to another data type

User-defined data type

Composite data type


With reference to at least one other data types
Enumerated data type
Enumerated data type
• Defines a list of possible values
Enumerated data type
• Property: imply order of values
Enumerated data type

Pointer data type


Pointer data type
• A reference to a memory location

^pointer
Number Memory address
Pointer data type
• A reference to a memory location

Number ← 15

Memory
Number Address
5846
Pointer data type
• A reference to a memory location

Number ← 15
IntPointer ← @Number

Assigns to IntPointer the address of the integer


variable Number

Memory
Number Address
5846
IntPointer
MyInt1 ← IntPointer^
Assigns to variable MyInt1 the value at an address pointed at by IntPointer

Memory
MyInt1 Address
3427
IntPointer^ ← MyInt2
IntPointer

Memory
Address
MyInt2 3426
Enumerated data type

Pointer data type

Record data type


Record data type
• Collect together values with different data types
Record data type in python
Enumerated data type

Pointer data type

Record data type

Set data type


Set data type
Enumerated data type

Pointer data type

Record data type

Set data type

Objects and classes


Objects and classes

Class 是一个组的统称, 比如说每个学生都有学号、姓名、班级、授课老师

Objects 是一个 class 的实例(相当于例子),


比如:小明学号 0028 ,姓名小明,班级高三 17 ,授课老师李乐乐
How to create an object and use it to create
classes?
Why are user-defined data
type necessary?
Why?
• No suitable data type is provided by the language used.
• The programmer needs to specify a new data type
• That meets the requirements of the application
Enumerated data type

Pointer data type

Record data type

Set data type

Objects and classes


End part1

You might also like