V2EX  ›  英汉词典

Upcast

释义 Definition

upcast(动词)常指在编程/类型系统中把较具体(子类、低精度、窄类型)的值或对象转换为较一般(父类、高精度、宽类型)的类型;也可泛指“向上转换/提升类型”。在部分语境里还可作名词,指这种转换本身。

发音 Pronunciation (IPA)

/ˌʌpˈkæst/

例句 Examples

The function upcasts the integer to a float.
这个函数把整数向上转换为浮点数。

In object-oriented programming, you can upcast a subclass instance to its base type to write more general code, though you may lose access to subclass-specific methods.
在面向对象编程中,你可以把子类实例向上转型为基类类型来编写更通用的代码,但可能会失去对子类特有方法的访问。

词源 Etymology

由 **up-**(向上、提升)+ cast(投掷、转换/塑形)构成。在计算机科学里,“cast”常指“类型转换”,加上“up-”就强调从更“低/窄/具体”的类型转到更“高/宽/一般”的类型;与 downcast(向下转型)相对。

相关词 Related Words

文学作品 Literary Works

  • The C++ Programming Language — Bjarne Stroustrup
  • Effective Java — Joshua Bloch
  • Programming in Scala — Martin Odersky, Lex Spoon, Bill Venners
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1779 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 16:01 · PVG 00:01 · LAX 08:01 · JFK 11:01
♥ Do have faith in what you're doing.