17.9 Operators

原创 2006年05月21日 02:48:00
An operator is a member that defines the meaning of an expression operator
that can be applied to instances of
the class. Operators are declared using operator-declarations:
operator-declaration:
attributesopt operator-modifiers operator-declarator operator-body
operator-modifiers:
operator-modifier
operator-modifiers operator-modifier
operator-modifier:
public
static
extern
operator-declarator:
unary-operator-declarator
binary-operator-declarator
conversion-operator-declarator
unary-operator-declarator:
type operator overloadable-unary-operator ( type identifier )
overloadable-unary-operator: one of
+ - ! ~ ++ -- true false
Chapter 17 Classes
255
binary-operator-declarator:
type operator overloadable-binary-operator ( type identifier , type
identifier )
overloadable-binary-operator: one of
+ - * / % & | ^ << >> == != > < >= <=
conversion-operator-declarator:
implicit operator type ( type identifier )
explicit operator type ( type identifier )
operator-body:
block
;
There are three categories of overloadable operators: Unary operators (§17.9
.1), binary operators (§17.9.2), and
conversion operators (§17.9.3).
When an operator declaration includes an extern modifier, the operator is
said to be an external operator.
Because an external operator provides no actual implementation, its
operator-body consists of a semi-colon. For
all other operators, the operator-body consists of a block, which specifies
the statements to execute when the
operator is invoked. The block of an operator must conform to the rules for
value-returning methods described in
§17.5.8.
The following rules apply to all operator declarations:
? An operator declaration must include both a public and a static modifier.
? The parameter(s) of an operator must be value parameters. It is a
compile-time error for an operator
declaration to specify ref or out parameters.
? The signature of an operator (§17.9.1, §17.9.2, §17.9.3) must differ
from the signatures of all other operators
declared in the same class.
? All types referenced in an operator declaration must be at least as
accessible as the operator itself (§10.5.4).
? It is an error for the same modifier to appear multiple times in an
operator declaration.
Each operator category imposes additional restrictions, as described in the
following sections.
Like other members, operators declared in a base class are inherited by
derived classes. Because operator
declarations always require the class or struct in which the operator is
declared to participate in the signature of
the operator, it is not possible for an operator declared in a derived
class to hide an operator declared in a base
class. Thus, the new modifier is never required, and therefore never
permitted, in an operator declaration.
Additional information on unary and binary operators can be found in §14.2.
Additional information on conversion operators can be found in §13.4.

Climate Data Operators 软件

netcdf文件格式 与 grid文件格式 转换
  • sudaobo
  • sudaobo
  • 2012年02月15日 10:46
  • 1166

【LeetCode】Expression Add Operators

Expression Add Operators  My Submissions Question Solution  Total Accepted: 1506 Total Submissions: ...
  • u013027996
  • u013027996
  • 2015年09月24日 17:19
  • 3266

multi update only works with $ operators

执行更新语句报错:multi update only works with $ operators 查看更新语句格式: db.c4.up...
  • dingsai88
  • dingsai88
  • 2015年01月28日 10:11
  • 4125

[leetcode 282]Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add b...
  • ER_Plough
  • ER_Plough
  • 2015年09月21日 11:26
  • 1230

Aspose.Cells 8月新版17.8发布 | 附下载

Aspose.Cells 8月新版17.8更新。
  • cocacola456
  • cocacola456
  • 2017年08月16日 14:17
  • 333

282. Expression Add Operators

这道题基本属于典型无脑dfs,跟word break有一点点的类似,都是给一个长串字母然后进行分割。 但是要注意的是如果要添加乘法运算符,需要先减去上一个添加的值然后再添加当前新的值和上一个值的乘积。...
  • revoir
  • revoir
  • 2016年04月16日 14:05
  • 348

leetcode:ExpressionAddOperators282 细致讲解 以及代码实现

Given a string that contains only digits 0-9 and a target value, return all possibilities to add b...
  • tingting256
  • tingting256
  • 2015年10月24日 14:27
  • 556

Oracle Operators

An operator manipulates individual data items and returns a result.This chapter contains these secti...
  • chunguangtang
  • chunguangtang
  • 2010年08月18日 14:46
  • 682

LeetCode-282. Expression Add Operators (JAVA)表达式求值

LeetCode-282. Expression Add Operators (JAVA)表达式求值
  • mine_song
  • mine_song
  • 2017年04月30日 17:35
  • 273

Python中Boolean operator的一些特点

今天在网站上学习Learn Python The Hard Way,Exercise 28(http://learnpythonthehardway.org/book/ex28.html)时,[Com...
  • xinweihome
  • xinweihome
  • 2013年11月28日 20:49
  • 923
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:17.9 Operators
举报原因:
原因补充:

(最多只允许输入30个字)