C ++表达式何时形成? [英] When is a C++ expression well formed?

查看:106
本文介绍了C ++表达式何时形成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跳过C ++标准,在很多情况下我都会提到以下语句:

Skimming through the C++ standard I came in quite a few cases to the statement:

表达式X应该格式正确.

The expression X shall be well formed.

我对自己说:好吧,直觉上您知道什么是格式正确的表达式,但是您可以对C ++表达式如何构成格式正确的表达式进行正式解释吗?".

I said to my self "OK, intuitively you know what a well formed expression is, but can you give a formal explanation of what makes a C++ expression a well formed expression?".

我搜索了一下,但没有发现任何可以正式解释此事的东西.所以这是我的问题:

I searched a little bit and I didn't find anything that gives a formal explanation on the matter. So here's my question:

问::C ++中格式正确的表达式的定性特征是什么?

Q: What are the qualitative characteristics of a well formed expression in C++?

推荐答案

格式正确的表达式必须符合表达式的语法(如标准所定义),并且必须符合语义规则,例如不使用尚未声明的名称,或不重新声明具有相同含义的相同作用域中的名称.

A well-formed expression must conform to the grammar for an expression (as defined by the standard) and must conform to the semantic rules, such as not using names which have not been declared, or not redeclaring a name in the same scope with a different meaning.

i = 0

X::i++

上面的表达式在语法上有效,但是如果未声明iconstX不是名称空间或类类型,或者未声明X::i不支持后递增,则它们不能满足格式正确的表达式的语义要求.

The expressions above are syntactically valid, but if i has not been declared, or is const, or X is not a namespace or class type, or X::i has not been declared, or X::i does not support post-increment, then they fail to meet the semantic requirements for a well-formed expression.

问:C ++中格式正确的表达式的定性特征是什么?

Q: What are the qualitative characteristics of a well formed expression in C++?

请参阅第1至15章.您不能将整个C ++语言简化为一个简单的列表.

See Clauses 1 to 15. You can't reduce the entire C++ language to a simple list.

这篇关于C ++表达式何时形成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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