后续:C ++ 14/C ++ 17中的变量到底是什么? [英] Follow-up: What exactly is a variable in C++14/C++17?

查看:48
本文介绍了后续:C ++ 14/C ++ 17中的变量到底是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,此问题已在之前提出.但是,答案与C ++ 03/有关.0x(11).C ++ 11(N3337)谈到变量:

As the title suggests, this question has been asked before. However, the answers pertained to C++03/0x(11). C++11 (N3337) says this about variables:

[basic]/6 :

变量 是通过声明非静态数据成员或对象以外的引用来引入的.变量的名称表示引用或对象.

A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable’s name denotes the reference or object.

这可能意味着变量本质上被命名为对象/引用.

This may imply that variables are essentially named objects/references.

但是,在 C ++ 14 / C ++ 17 ,最后一句话改为

However, in C++14/C++17, that last sentence was changed to

变量名(如果有),表示引用或对象.

表示变量 not 不一定具有名称.

which implies that a variable does not necessarily have a name.

对第一句话的不同解释可能表明变量是一个名称,因为表示对象/引用的 name 也通过此类实体的声明引入..但是第二句话与变量名称"一词相矛盾.那么,变量现在是否只是 object reference 的代名词,无论是否命名?

A different interpretation of the first sentence may suggest that a variable is a name, since a name denoting an object/reference is also introduced by a declaration of such entities. But the second sentence contradicts that notion with the phrase "variable's name". So, is variable now just a hypernym for object and reference, whether named or not?

推荐答案

此更改是

This change was a result of CWG 1769, addressing the status of exception objects bound to unnamed catch handler parameters:

catch (std::exception&) // <==
{ 
}

现在是一个变量.这简化了围绕异常对象的概念模型.

That is now a variable. This simplifies the conceptual model around exception objects.

第一句话(保持不变)仍然是术语变量的完整定义.

The first sentence, which remained unchanged, is still the complete definition of the term variable.

这篇关于后续:C ++ 14/C ++ 17中的变量到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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