gpt4 book ai didi

c++ - C++ 中的 "literal"是什么?

转载 作者:IT老高 更新时间:2023-10-28 23:03:37 24 4
gpt4 key购买 nike

Possible Duplicate:
What does the word “literal” mean?

在阅读有关 C++ 的文献时,我经常会遇到“literal”这个词。我有点不清楚这个术语在 C++ 中的确切含义。

最佳答案

文字是直接在代码中呈现的一些数据,而不是通过变量或函数调用间接呈现。

以下是一些示例,每行一个:

42
128
3.1415
'a'
"hello world"

构成文字的数据不能被程序修改,但可以复制到变量中以供进一步使用:

int a = 42;  // creates variable `a` with the same value as the literal `42`

This concept is by no means unique to C++ .

“字面量”一词源于您已写入数据 literally进入你的程序,即完全按照书面形式,而不是“隐藏”在变量名后面。

关于c++ - C++ 中的 "literal"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14111329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com