const变量悖论 [英] const variable paradox
本文介绍了const变量悖论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在c ++上有一些表达式:
if I have some expression on c++:
const int x = 3;
我可以说x是一个变量吗?似乎很奇怪因为x不是变量,因为我不能改变它,任何扩展提前感谢
can I say that x is a variable? It seems very strange cause x is not variable cause I can't change it, thanks in advance for any expanations
编辑
PS感谢所有的答案,我明白,通过C ++的定义,回答我的问题可能是,你知道一些其他语言,其中我的问题的答案将不是吗?
Edited P.S. thanks for all answers, I understood that by definition of C++, answer for my question may be yes, do You know some other languages, in which the answer for my question will be no?
推荐答案
是的。 x
是一个变量,即使您不能(合法地)更改其值。
Yes. x
is a variable, even though you cannot (legitimately) change its value.
具有名称的对象是变量。
Effectively, in C++, an object that has a name is a "variable."
这篇关于const变量悖论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文