fbpx
维基百科

值类型与引用类型

计算机编程中的数据类型可分为两族:值类型(value type)与引用类型(reference type)。值类型的值就是实际值。引用类型的值是到其他值的引用[1][2]

各种编程语言的分类

语言 值类型 引用类型
C++[3] 布尔值、字符、整数、浮点数、类(包括字符串、列表、映射、集合、堆栈、队列)、枚举 参考,指针
Java[4] 布尔值、字符、整数、浮点数 数组、类(包括不可变字符串、列表、字典、集合、堆栈、队列、枚举)、接口、空指针
C#[5] structures (including booleans, characters, integer numbers, floating-point numbers, fixed-point numbers, lists, dictionaries, sets, stacks, queues, optionals), enumerations classes (including immutable strings, arrays, tuples, lists, dictionaries, sets, stacks, queues), interfaces, pointers
Swift[6][7] structures (including booleans, characters, integer numbers, floating-point numbers, fixed-point numbers, mutable strings, tuples, mutable arrays, mutable dictionaries, mutable sets), enumerations (including optionals), and user-defined structures and enumerations composing other value types. functions, closures, classes
Python[8] classes (including immutable booleans, immutable integer numbers, immutable floating-point numbers, immutable complex numbers, immutable strings, byte strings, immutable byte strings, immutable tuples, immutable ranges, immutable memory views, lists, dictionaries, sets, immutable sets, null pointer)
JavaScript[9] immutable booleans, immutable floating-point numbers, immutable integer numbers (bigint), immutable strings, immutable symbols, undefined, null objects (including functions, arrays, typed arrays, sets, maps, weak sets and weak maps)
OCaml[10][11] immutable characters, immutable integer numbers, immutable floating-point numbers, immutable tuples, immutable enumerations (including immutable units, immutable booleans, immutable lists, immutable optionals), immutable exceptions, immutable formatting strings arrays, immutable strings, byte strings, dictionaries (including pointers)

装箱和拆箱(boxing and unboxing)

区分值类型与引用类型的语言,典型包括了装箱机制。即把一些甚至全部值类型包为引用类型。这使得值类型可用在需要引用类型的场合。逆过程称为拆箱。

参见

参考文献

  1. ^ Brown, Erik E. Windows Forms in Action. Shelter Island, New York: Manning. 2006: 703. ISBN 978-1-932-39465-8. 
  2. ^ Stephens, Rod. C# 5.0 Programmer's Reference. Indianapolis, Indiana: John Wiley & Sons. 2014: 57. ISBN 978-1-118-84728-2. 
  3. ^ . en.cppreference.com. [2021-01-08]. (原始内容存档于2020-11-13). 
  4. ^ . docs.oracle.com. [2021-01-08]. (原始内容存档于2020-08-29). 
  5. ^ . docs.microsoft.com. [2021-01-08]. (原始内容存档于2020-11-26). 
  6. ^ . docs.swift.org. [2021-01-08]. (原始内容存档于2020-12-11). 
  7. ^ . docs.swift.org. [2021-01-08]. (原始内容存档于2021-02-06). 
  8. ^ . docs.python.org. [2021-01-08]. (原始内容存档于2020-06-14). 
  9. ^ . www.ecma-international.org. [2021-01-08]. (原始内容存档于2021-01-13). 
  10. ^ . caml.inria.fr. [2021-01-08]. (原始内容存档于2020-07-02). 
  11. ^ . caml.inria.fr. [2021-01-08]. (原始内容存档于2020-07-22). 

值类型与引用类型, 此條目目前正依照其他维基百科上的内容进行翻译, 2021年1月15日, 如果您擅长翻译, 並清楚本條目的領域, 欢迎协助翻譯, 改善或校对本條目, 此外, 长期闲置, 未翻譯或影響閱讀的内容可能会被移除, 计算机编程中的数据类型可分为两族, 值类型, value, type, 与引用类型, reference, type, 值类型的值就是实际值, 引用类型的值是到其他值的引用, 目录, 各种编程语言的分类, 装箱和拆箱, boxing, unboxing, 参见, 参考文献各种编程语言的分类, . 此條目目前正依照其他维基百科上的内容进行翻译 2021年1月15日 如果您擅长翻译 並清楚本條目的領域 欢迎协助翻譯 改善或校对本條目 此外 长期闲置 未翻譯或影響閱讀的内容可能会被移除 计算机编程中的数据类型可分为两族 值类型 value type 与引用类型 reference type 值类型的值就是实际值 引用类型的值是到其他值的引用 1 2 目录 1 各种编程语言的分类 2 装箱和拆箱 boxing and unboxing 3 参见 4 参考文献各种编程语言的分类 编辑语言 值类型 引用类型C 3 布尔值 字符 整数 浮点数 类 包括字符串 列表 映射 集合 堆栈 队列 枚举 参考 指针Java 4 布尔值 字符 整数 浮点数 数组 类 包括不可变字符串 列表 字典 集合 堆栈 队列 枚举 接口 空指针C 5 structures including booleans characters integer numbers floating point numbers fixed point numbers lists dictionaries sets stacks queues optionals enumerations classes including immutable strings arrays tuples lists dictionaries sets stacks queues interfaces pointersSwift 6 7 structures including booleans characters integer numbers floating point numbers fixed point numbers mutable strings tuples mutable arrays mutable dictionaries mutable sets enumerations including optionals and user defined structures and enumerations composing other value types functions closures classesPython 8 classes including immutable booleans immutable integer numbers immutable floating point numbers immutable complex numbers immutable strings byte strings immutable byte strings immutable tuples immutable ranges immutable memory views lists dictionaries sets immutable sets null pointer JavaScript 9 immutable booleans immutable floating point numbers immutable integer numbers bigint immutable strings immutable symbols undefined null objects including functions arrays typed arrays sets maps weak sets and weak maps OCaml 10 11 immutable characters immutable integer numbers immutable floating point numbers immutable tuples immutable enumerations including immutable units immutable booleans immutable lists immutable optionals immutable exceptions immutable formatting strings arrays immutable strings byte strings dictionaries including pointers 装箱和拆箱 boxing and unboxing 编辑区分值类型与引用类型的语言 典型包括了装箱机制 即把一些甚至全部值类型包为引用类型 这使得值类型可用在需要引用类型的场合 逆过程称为拆箱 参见 编辑基本类型 複合型別参考文献 编辑 Brown Erik E Windows Forms in Action Shelter Island New York Manning 2006 703 ISBN 978 1 932 39465 8 Stephens Rod C 5 0 Programmer s Reference Indianapolis Indiana John Wiley amp Sons 2014 57 ISBN 978 1 118 84728 2 Type cppreference com en cppreference com 2021 01 08 原始内容存档于2020 11 13 Chapter 4 Types Values and Variables docs oracle com 2021 01 08 原始内容存档于2020 08 29 C Keywords docs microsoft com 2021 01 08 原始内容存档于2020 11 26 Structures and Classes The Swift Programming Language Swift 5 2 docs swift org 2021 01 08 原始内容存档于2020 12 11 Closures The Swift Programming Language Swift 5 2 docs swift org 2021 01 08 原始内容存档于2021 02 06 Built in Types Python 3 8 2rc1 documentation docs python org 2021 01 08 原始内容存档于2020 06 14 ECMAScript 2019 Language Specification www ecma international org 2021 01 08 原始内容存档于2021 01 13 Chapter 24 The core library caml inria fr 2021 01 08 原始内容存档于2020 07 02 Modifiable Data Structures caml inria fr 2021 01 08 原始内容存档于2020 07 22 取自 https zh wikipedia org w index php title 值类型与引用类型 amp oldid 76340716, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。