Quote
不管什么数在计算机里都是二进制的数, 重点是我们怎么看他, 体现了不同的数据类型 —— 翁恺
Quote
A type defines both the contents of a data element and the operations that are possible on those data. (C++ Primer, p32)
(class也是这个味道吧)
可以用这个 🔗sizeof 来计算一个 type 占据了多少空间。
Machine-Level Representation of the Built-in Types
The smallest chunk of addressable memory is referred to as a “byte”
a small number of bytes, is referred to as a “word”
In C++ a byte has at least to hold a character in the machine’s basic character set
Most computers associate address with each byte in memory.
The type determines how many bits are used and how to interpret those bits
type 决定了这个地址上的 object span 了多少 memory. 所以说是这样一个 byte?还是那样一个 word?
Primitive Built-in Types
include the arithmetic types and a special type named void
.
the arithmetic types represent characters, integers, boolean values, and floating-point numbers.
Arithemtic Types
this types are divided into: 🔗Integral Types and 🔗Floating-point Types. (对照前文判断一下谁是整数型,谁是浮点型)
for integral types, there exsist 🔗Signed and Unsigned Types
Compound Types
A compound type is a type that is defined in terms of another type.
🔗References and 🔗Pointers are two compound types. They are similar in some circumstance.
🔗Arrays is also a compound type.
compound compound typeswhen the two compound “refrence to pointers”, we read the definition right to left.
int *&r = p; // r is a reference to the pointer p
the first modifier
&
indicates r is a reference, and the specifierint*
says r is refer to a pointer.
Literals
Type Conversions
const and Constant Expressions
Type Aliases
🌟Type Specifiers
Library Types
type | template |
---|---|
🔗string | 🔗vector |
🔗initializer_list |