标运算符后缀 [英] subscript operator postfix
问题描述
C ++标准定义了使用标为后缀的前pression除权pression。据我所知,这个操作符总是有两个参数(第一个是指向T和另一种是枚举或整型)。因此,它应该有资格作为一个二元运算。
The C++ standard defines the expression using subscripts as a postfix expression. AFAIK, this operator always takes two arguments (the first is the pointer to T and the other is the enum or integral type). Hence it should qualify as a binary operator.
不过 MSDN 和<一个href=\"http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr324.htm\"相对=nofollow> IBM 没有列出它作为一个二元运算符。
However MSDN and IBM does not list it as a binary operator.
所以,问题是,什么是下标运算符?它是一元或二进制?可以肯定的,因为它不是在(至少straigt远)提到的$ 5.3是不是一元。
So the question is, what is subscript operator? Is it unary or binary? For sure, it is not unary as it is not mentioned in $5.3 (at least straigt away).
这是什么意思时,标准提到它在后缀前pression的?
What does it mean when the Standard mentions it's usage in the context of postfix expression?
推荐答案
您是正确的,运算符[]
是一个二元运算符,但它是特殊的,它也必须是一个成员函数。
You are correct that operator[]
is a binary operator but it is special in that it must also be a member function.
类似操作符()
您可以前后缀pressions的这里
You can read up on postfix expressions here
我刚刚发现关于运算符[]
和后缀前pression,的这里
I just found an interesting article about operator[]
and postfix expression, here
这篇关于标运算符后缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!