V2EX  ›  英汉词典

Casting Operator

Definition / 定义

casting operator(类型转换运算符):在编程语言中,用于把一个值从一种数据类型转换为另一种数据类型的运算符或语法形式。常见于 C/C++(如 (int)x)、C#(如 (int)x)、Java(如 (int)x)等语言(不同语言的写法与规则可能不同)。

Pronunciation / 发音

/ˈkæstɪŋ ˈɑːpəreɪtər/

Examples / 例句

I used a casting operator to convert the float to an int.
我用了类型转换运算符把浮点数转换成整数。

If you apply a casting operator to an object without checking its type, the program may throw an error at runtime.
如果你不先检查类型就对对象使用类型转换运算符,程序可能会在运行时抛出错误。

Etymology / 词源

cast 原意有“投掷、铸造、塑形”的意思,在编程语境里引申为“把数据‘塑形’成另一种类型”,即“类型转换”。operator 来自拉丁语 operari(工作、操作),在计算机领域指“执行某种操作的符号或关键字”。合起来就是“执行类型转换的运算符”。

Related Words / 相关词

Literary Works / 文学与著作例证

  • The C++ Programming Language(Bjarne Stroustrup)——讨论 C++ 中的类型转换与相关运算符(如 C 风格转换、static_cast 等)。
  • Effective Java(Joshua Bloch)——涉及 Java 中的类型转换、向下转型与类型安全。
  • C# in Depth(Jon Skeet)——讲解 C# 的显式/隐式转换与转换运算符在语言中的行为。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3036 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 09:45 · PVG 17:45 · LAX 01:45 · JFK 04:45
♥ Do have faith in what you're doing.