upcast(动词)常指在编程/类型系统中把较具体(子类、低精度、窄类型)的值或对象转换为较一般(父类、高精度、宽类型)的类型;也可泛指“向上转换/提升类型”。在部分语境里还可作名词,指这种转换本身。
/ˌʌpˈkæst/
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.
在面向对象编程中,你可以把子类实例向上转型为基类类型来编写更通用的代码,但可能会失去对子类特有方法的访问。
由 **up-**(向上、提升)+ cast(投掷、转换/塑形)构成。在计算机科学里,“cast”常指“类型转换”,加上“up-”就强调从更“低/窄/具体”的类型转到更“高/宽/一般”的类型;与 downcast(向下转型)相对。