变量是真实的吗? [英] Are variables real things?

查看:44
本文介绍了变量是真实的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 C++,我想知道变量是否真实存在.它们是否在计算机中编译器与之对话的某个地方?

I'm learning C++ and I want to know if variables are real things. Are they in the computer some where that the compiler talks to?

推荐答案

变量是 C++ 抽象机器中的概念,在您的计算机中可能有也可能没有具体的对应物.不那么严密守卫的秘密是 C++ 抽象机不容易获得(它们是抽象的!),因此我们使用一些非常智能的工具,即编译器,来模拟 C++ 抽象机在您的系统中的行为.物理的、具体的计算机.

Variables are concepts in the C++ abstract machine that may or may not have a concrete counterpart in your computer. The not-so-closely guarded secret is that C++ abstract machines are not easy to come by (they're abstract!), so instead we use some very smart tools, the compilers, to emulate the behaviour of a C++ abstract machine in your physical, concrete computer.

编译器会尝试将 C++ 抽象机中的概念映射到计算机中存在的事物,但这些映射不必 100% 准确.编译器通常会跳过将某些变量映射到任何东西的过程,因为它们可以使您的程序表现得就像在 C++ 抽象机器中运行一样,而无需映射它们.这只是编译器用来保持程序运行在其中一台抽象机器上而不是计算机上的错觉的众多技巧之一.

The compilers will try to map concepts in the C++ abstract machine to things that exist in your computer, but those mappings don't have to be 100% exact. Compilers will often skip mapping some variables to anything at all, because they can make your program behave as if it was running in a C++ abstract machine without mapping them. This is just one of the many tricks that compilers will use to keep the illusion that your program is running in one of those abstract machines instead of your computer.

这是否意味着变量是真实的"?这听起来像是哲学中的一个老问题:数字是真实的吗?

Does that mean the variables are "real"? That sounds just like an old question from philosophy: are numbers real?

这篇关于变量是真实的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆