operator是C#、C++和pascal的关键字,它和运算符一起使用,表示一个运算符函数,理解时应将operator=整体上视为一个函数名。
中文名Operator
属于C++的关键字
用法运算符一起使用
表示一个运算符函数
关键字这是C++扩展运算符功能的方法,虽然样子古怪,但也可以理解:一方面要使运算符的使用方法与其原来一致,另一方面扩展其功能只能通过函数的方式(c++中,“功能”都是由函数实现的)。
在symbian os c++中,返回const TUint&给描述符数据的一个指定的单个数据项。使用operator[]在描述符上循环的代价是昂贵的;替代的方法是考虑使用C++算数指针和TDesc::Ptr()。
operator在.Net中的应用,在.Net中自身的状态机制都有现成的操作集合的范本,像需要Add +=;需要Rmove -=;让软件开发者在操作的时候更简洁些,使用可重载操作的时候,更“不拘一格”;代码如:
public class ErrorEntity
{
private IList messages=new List();
private IList codes=new List();
public static ErrorEntity operator+(ErrorEntity entity,string str)
{
entity.messages.Add(str);
return entity;
}
public static ErrorEntity operator+(ErrorEntity entity,int code)
{
entity.codes.Add(code);
return entity;
}
public static ErrorEntity operator-(ErrorEntity entity,string str)
{
entity.messages.Remove(str);
return entity;
}
public static ErrorEntity operator-(ErrorEntity entity,int code)
{
entity.codes.Remove(code);
return entity;
}
public IList Messages{get{return messages;}}
public IList Codes{get{return codes;}}
}
定义运算可以定义运算符,让程序比较简洁。
来一个比较丑的高精加定义
1operator+(a,b:sz)c:sz;
2vari,ni:longint;
3begin
4fillchar(c,sizeof(c),0);
5ni:=a[0];
6ifni<b[0]thenni:=b[0];
7fori:=1tonido
8begin
9c[i]:=c[i]+b[i]+a[i];
10ifc[i]>9then
11begin
12inc(c[i+1],c[i]div10);
13c[i]:=c[i]mod10;
14end;
15end;
16ifc[ni+1]>0theninc(ni);
17c[0]:=ni;
18end.
单词名词n.[C]
1.操作者,技工
2.司机
3.接线员
He dialed the operator.
他拨通了接线员。
4.施行手术的医生
5.(企业)经营者
6.精明圆滑的人
7.【数】(运)算子,算符
8.旅行社计调人员
参考资料本文发布于:2023-06-05 17:15:36,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/zhishi/a/92/207592.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Operator(计算机术语).doc
本文 PDF 下载地址:Operator(计算机术语).pdf
| 留言与评论(共有 0 条评论) |