演员是一元还是二元?有多少个操作数? [英] Is cast operator unary or binary? How many operands?

查看:71
本文介绍了演员是一元还是二元?有多少个操作数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运算符和操作数如何表示(typename)表达式?


我会说一个运算符,转换运算符和两个操作数:typename

和表达式。


但是在我读到的每个地方,演员被归类为一元运算符。为什么

是那个?这只是一个语法cotegory吗?


谢谢。

$ b $bJoséMaría。

How may operators and operands does (typename) expression has?

I''d say one operator, the cast operator, and two operands: typename
and expression.

But everywhere I read, cast is categorized as an unary operator. Why
is that? Is it just a syntax cotegory?

Thanks.

José María.

推荐答案

4月29日下午3:45,JoseMariaSola< JoseMariaS ... @ gmail.comwrote:
On Apr 29, 3:45 pm, JoseMariaSola <JoseMariaS...@gmail.comwrote:

操作员和操作数怎么办? (typename)表达式有?


我会说一个运算符,强制转换运算符和两个操作数:typename

和expression。


但是在我读到的每个地方,演员被归类为一元运算符。为什么

是那个?它只是一个语法cotegory?
How may operators and operands does (typename) expression has?

I''d say one operator, the cast operator, and two operands: typename
and expression.

But everywhere I read, cast is categorized as an unary operator. Why
is that? Is it just a syntax cotegory?



(typename)(表达式)有一个运算符`(typename)''和一个操作数

`(表达式)''。

类型括在括号中的原因(作为设计决定)

可能是为了避免含糊不清,考虑一下:


int i = 1; / *定义并初始化为1 * /

{

int i; / *将i转换为int,一个无效的语句,或者在

块范围中定义i? * /

}

(typename)(expression) has one operator `(typename)'' and one operand
`(expression)''.
The reason the type is enclosed in parentheses (as a design decision)
is probably to avoid ambiguity, consider this:

int i = 1; /* define and initialize i to 1 */
{
int i; /* cast i to int, a statement with no effect, or define i in
block scope? */
}


我会说一个运算符,转换运算符和两个操作数:typename
I''d say one operator, the cast operator, and two operands: typename

和表达式。
and expression.


但是在我读到的每个地方,演员被归类为一元运算符。为什么

是那个?它只是一个语法cotegory?
But everywhere I read, cast is categorized as an unary operator. Why
is that? Is it just a syntax cotegory?



(typename)(表达式)有一个运算符`(typename)''和一个操作数

`(表达式)''。

类型括在括号中的原因(作为设计决定)

可能是为了避免含糊不清,考虑一下:


int i = 1; / *定义并初始化为1 * /

{

int i; / *将i转换为int,一个无效的语句,或者在

块范围中定义i? * /


}


(typename)(expression) has one operator `(typename)'' and one operand
`(expression)''.
The reason the type is enclosed in parentheses (as a design decision)
is probably to avoid ambiguity, consider this:

int i = 1; /* define and initialize i to 1 */
{
int i; /* cast i to int, a statement with no effect, or define i in
block scope? */

}



谢谢,Vipps。


根据你的回答,运算符''(typename)''非常特别,因为它不是单个令牌而是三个和中间

令牌是标识符可能是什么。


JM。

Thanks, Vipps.

According to your answeer, the operator ''(typename)'' is very
particular, because it not a single token but three AND the middle
token is anything an identifier may be.

JM.


4月29日下午1:47,JoseMariaSola< JoseMariaS ... @ gmail.comwrote:
On Apr 29, 1:47 pm, JoseMariaSola <JoseMariaS...@gmail.comwrote:

我会说一个运算符,转换运算符和两个操作数:typename

和表达式。
I''d say one operator, the cast operator, and two operands: typename
and expression.


但是在我读到的每个地方,cast都被归类为一元运算符。为什么

是那个?它只是一个语法cotegory?
But everywhere I read, cast is categorized as an unary operator. Why
is that? Is it just a syntax cotegory?


(typename)(表达式)有一个运算符`(typename)''和一个操作数

`(表达式)''。

类型括在括号中的原因(作为设计决定)

可能是为了避免含糊不清,请考虑:
(typename)(expression) has one operator `(typename)'' and one operand
`(expression)''.
The reason the type is enclosed in parentheses (as a design decision)
is probably to avoid ambiguity, consider this:


int i = 1; / *定义并初始化为1 * /

{

int i; / *将i转换为int,一个无效的语句,或者在

块范围中定义i? * /
int i = 1; /* define and initialize i to 1 */
{
int i; /* cast i to int, a statement with no effect, or define i in
block scope? */


}
}



谢谢,Vipps。


根据您的回答者,运营商''(typename)''非常特别是
,因为它不是一个令牌而是三个和中间

令牌是标识符可能是的任何东西。


JM。


Thanks, Vipps.

According to your answeer, the operator ''(typename)'' is very
particular, because it not a single token but three AND the middle
token is anything an identifier may be.

JM.



我上一篇文章的最后一行是:

...中间令牌是标识符可能包含的任何内容。 br />

这是语法的一部分:


一元表达式:

后缀表达式

++ unary-expression

- 一元表达式

一元运算符cast-expression

sizeof一元表达式

sizeof(类型名称)


一元运营商:

& * + - ? !


cast-expression:

一元表达式

(类型名称)cast-expression

为什么sizeof,(type-name),++和 - 不是一元运算符?


谢谢。

The last line of my last post shoudl be:
... the middle token is anything an identifier may be and more.

Here is part of the grammar:

unary-expression:
postfix-expression
++ unary-expression
-- unary-expression
unary-operator cast-expression
sizeof unary-expression
sizeof ( type-name )

unary-operator: one of
& * + - ? !

cast-expression:
unary-expression
( type-name ) cast-expression
Why sizeof, (type-name), ++ and -- aren''t unary-operators?

Thanks.


这篇关于演员是一元还是二元?有多少个操作数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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