| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> dui C++ di zeng ( zeng liang ) yun suan fu chong zai de si kao

dui C++ di zeng ( zeng liang ) yun suan fu chong zai de si kao

2008-06-01 02:04:52 编辑來源:互联网 评论
 
 
 
本文为【对C++递增(增量)运算符重载的思考】的拼音翻译版
  zai qian mian de zhang jie zhong wo men yi jing jie chu guo di zeng yun suan fu de chong zai , na shi hou wo men bing mei you qu fen qian di zeng yu hou di zeng de cha bie , zai tong chang qing kuang xia wo men shi fen bie bu chu ++a yu a++ de cha bie de , dan de que ta men zhi jie shi cun zai ming xian cha bie de 。
  xian kan ru xia dai ma :
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  #include <iostream>
  using namespace std;
  
  int main()
  {
   int a=0;
   ++(++a);// zheng que ,(++a) fan hui de shi zuo zhi
   (a++)++;// cuo wu ,(a++) fan hui de bu shi zuo zhi
   system("pause");
  } dai ma zhong (a++)++ bian yi chu cuo wu , fan hui “++” xu yao zuo zhi de cuo wu , zhe zheng shi qian di zeng yu hou di zeng de cha bie dao zhi de , na me you shi wei shen me ne ?
  yuan yin zhu yao shi you C++ dui di zeng ( zeng liang ) yun suan fu de ding yi yin fa de 。
  ta men zhi jian de cha bie zhu yao wei yi xia liang dian :
  1、 yun suan guo cheng zhong , xian jiang dui xiang jin xing di zeng xiu gai , er hou fan hui gai dui xiang ( qi shi jiu shi dui xiang de yin yong ) de jiao qian di zeng ( zeng liang ) yun suan 。 zai yun suan fu chong zai han shu zhong cai yong fan hui dui xiang yin yong de fang shi bian xie 。
  2、 yun suan guo cheng zhong , xian fan hui yuan you dui xiang de zhi , er hou jin xing dui xiang di zeng yun suan de jiao hou di zeng ( zeng liang ) yun suan 。 zai yun suan fu chong zai han shu zhong cai yong zhi fan hui de fang shi bian xie ( zhe ye zheng shi qian mian (a++)++ chu cuo wu de yuan yin ,(a++) fan hui de bu shi yin yong , bu neng dang zuo zuo zhi ji xu shen jia kuo hao wai bu de ++ yun suan ), chong zai han shu de nei bu shi xian bi xu chuang jian yi ge yong yu lin shi cun chu yuan you dui xiang zhi de dui xiang , han shu fan hui de shi hou jiu shi fan hui gai lin shi dui xiang 。 na me zai bian xie yun suan fu chong zai han shu de shi hou wo men gai ru he qu fen qian di zeng yun suan fu chong zai han shu yu hou di zeng yun suan fu chong zai han shu ne ?
  fang fa jiu shi : zai hou di zeng yun suan fu chong zai han shu de shen shu zhong duo jia ru yi ge int biao shi , biao ji wei hou di zeng yun suan fu chong zai han shu 。
  ju ti jian ru xia shi li ( li yi wei fei cheng yuan fang shi , li er wei cheng yuan fang shi ):// li yi
  // cheng xu zuo zhe : guan ning
  // zhan dian :www.cndev-lab.com
  // suo you gao jian yun you ban quan , ru yao zhuan zai , qing wu bi wen ming chu chu he zuo zhe
  
  #include <iostream>
  using namespace std;
  
  class Test
  {
   public:
   Test(int a=0)
   {
   Test::a = a;
   }
   friend Test& Operator ++ (Test&);
   friend Test operator ++ (Test&,int);
   public:
   int a;
  };
  Test& operator ++ (Test &temp)// qian di zeng
  {
   temp.a++;
   return temp;
  }
  Test operator ++ (Test &temp,int)// hou di zeng ,int zai zhe li zhi qi dao qu fen zuo yong , shi shi shang bing mei you shi ji zuo yong
  
   {
   Test rtemp(temp);// zhe li hui tiao yong kao bei gou zao han shu jin xing dui xiang de fu zhi gong zuo
   temp.a++;
   return rtemp;
  }
  int main()
  {
   Test a(100);
   ++(++a);
   cout<<a.a<<endl;
   cout<<" guan cha hou di zeng qing kuang xia lin shi cun chu dui xiang de zhi zhuang tai :"<<(a++).a<<endl;// zhe li zheng shi ti xian hou di zeng cao zuo xian fan hui yuan you dui xiang zhi di fang
   cout<<a.a<<endl;
   (a++)++;
   cout<<a.a<<endl;// you yu hou di zeng shi zhi fan hui zhuang tai , suo yi (a++)++ zhi dui a zuo le yi ci di zeng cao zuo , cao zuo hou wei 104 er fei 105。
   system("pause");
  }
  
对C++递增(增量)运算符重载的思考
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
  // li er
  // cheng xu zuo zhe : guan ning
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  // zhan dian :www.cndev-lab.com
  // suo you gao jian yun you ban quan , ru yao zhuan zai , qing wu bi wen ming chu chu he zuo zhe
  
  #include <iostream>
  using namespace std;
  
  class Test
  {
   public:
   Test(int a=0)
   {
   Test::a = a;
   }
   Test& operator ++ ();
   Test operator ++ (int);
   public:
   int a;
  };
  Test& Test::operator ++ ()// qian di zeng
  {
   this->a++;
   return *this;
  }
  Test Test::operator ++ (int)// hou di zeng
  {
   Test rtemp(*this);// zhe li hui tiao yong kao bei gou zao han shu jin xing dui xiang de fu zhi gong zuo
   this->a++;
   return rtemp;
  }
  int main()
  {
   Test a(100);
   ++(++a);
  
   cout<<a.a<<endl;
   cout<<" guan cha hou di zeng qing kuang xia lin shi cun chu dui xiang de zhi zhuang tai :"<<(a++).a<<endl;// zhe li zheng shi ti xian hou di zeng cao zuo xian fan hui yuan you dui xiang zhi di fang
   cout<<a.a<<endl;
   (a++)++;
   cout<<a.a<<endl;// you yu hou di zeng shi zhi fan hui zhuang tai , suo yi (a++)++ zhi dui a zuo le yi ci di zeng cao zuo , cao zuo hou wei 104 er fei 105。
   system("pause");
  } tong guo dui qian hou di zeng yun suan de fen xi , wo men ke yi jin yi bu ke yi le jie dao , dui yu xiang tong qing kuang de dan mu yun suan fu chong zai wo men dou bi xu zuo hao zhe xie qu bie gong zuo , bao zheng chong zai hou de yun suan fu fu he yao qiu 。
对C++递增(增量)运算符重载的思考
geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
   zai qian mian de zhang jie zhong wo men yi jing jie chu guo di zeng yun suan fu de chong zai , na shi hou wo men bing mei you qu fen qian di zeng yu hou di zeng de cha bie , zai tong chang qing kuang xia wo men shi fen bie bu chu ++a yu a++ de cha bie de , dan de que ta men zhi jie shi cun zai ming xian cha bie de 。    xian kan ru xia dai ma : #include <iostream> using namespace std; int main() { int a=0; ++(++a);// zheng que ,(++a) fan hui de shi zuo zhi (a++)++;// cuo wu ,(a++) fan hui de bu shi zuo zhi system("pause"); }    dai ma zhong (a++)++ bian yi chu cuo wu , fan hui “++” xu yao zuo zhi de cuo wu , zhe zheng shi qian di zeng yu hou di zeng de cha bie dao zhi de , na me you shi wei shen me ne ?    yuan yin zhu yao shi you C++ dui di zeng ( zeng liang ) yun suan fu de ding yi yin fa de 。 ta men zhi jian de cha bie zhu yao wei yi xia liang dian :   1、 yun suan guo cheng zhong , xian jiang dui xiang jin xing di zeng xiu gai , er hou fan hui gai dui xiang ( qi shi jiu shi dui xiang de yin yong ) de jiao qian di zeng ( zeng liang ) yun suan 。 zai yun suan fu chong zai han shu zhong cai yong fan hui dui xiang yin yong de fang shi bian xie 。   2、 yun suan guo cheng zhong , xian fan hui yuan you dui xiang de zhi , er hou jin xing dui xiang di zeng yun suan de jiao hou di zeng ( zeng liang ) yun suan 。 zai yun suan fu chong zai han shu zhong cai yong zhi fan hui de fang shi bian xie ( zhe ye zheng shi qian mian (a++)++ chu cuo wu de yuan yin ,(a++) fan hui de bu shi yin yong , bu neng dang zuo zuo zhi ji xu shen jia kuo hao wai bu de ++ yun suan ), chong zai han shu de nei bu shi xian bi xu chuang jian yi ge yong yu lin shi cun chu yuan you dui xiang zhi de dui xiang , han shu fan hui de shi hou jiu shi fan hui gai lin shi dui xiang 。   na me zai bian xie yun suan fu chong zai han shu de shi hou wo men gai ru he qu fen qian di zeng yun suan fu chong zai han shu yu hou di zeng yun suan fu chong zai han shu ne ?    fang fa jiu shi : zai hou di zeng yun suan fu chong zai han shu de shen shu zhong duo jia ru yi ge int biao shi , biao ji wei hou di zeng yun suan fu chong zai han shu 。    ju ti jian ru xia shi li ( li yi wei fei cheng yuan fang shi , li er wei cheng yuan fang shi ):// li yi // cheng xu zuo zhe : guan ning // zhan dian :www.cndev-lab.com // suo you gao jian yun you ban quan , ru yao zhuan zai , qing wu bi wen ming chu chu he zuo zhe #include <iostream> using namespace std; class Test { public: Test(int a=0) { Test::a = a; } friend Test& Operator ++ (Test&); friend Test operator ++ (Test&,int); public: int a; }; Test& operator ++ (Test &temp)// qian di zeng { temp.a++; return temp; } Test operator ++ (Test &temp,int)// hou di zeng ,int zai zhe li zhi qi dao qu fen zuo yong , shi shi shang bing mei you shi ji zuo yong { Test rtemp(temp);// zhe li hui tiao yong kao bei gou zao han shu jin xing dui xiang de fu zhi gong zuo temp.a++; return rtemp; } int main() { Test a(100); ++(++a); cout<<a.a<<endl; cout<<" guan cha hou di zeng qing kuang xia lin shi cun chu dui xiang de zhi zhuang tai :"<<(a++).a<<endl;// zhe li zheng shi ti xian hou di zeng cao zuo xian fan hui yuan you dui xiang zhi di fang cout<<a.a<<endl; (a++)++; cout<<a.a<<endl;// you yu hou di zeng shi zhi fan hui zhuang tai , suo yi (a++)++ zhi dui a zuo le yi ci di zeng cao zuo , cao zuo hou wei 104 er fei 105。 system("pause"); } [url=http://www.wangchao.net.cn/bbs/pydetail_1785324.html][img]http://image.wangchao.net.cn/it/1323423872553.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo // li er // cheng xu zuo zhe : guan ning // zhan dian :www.cndev-lab.com // suo you gao jian yun you ban quan , ru yao zhuan zai , qing wu bi wen ming chu chu he zuo zhe #include <iostream> using namespace std; class Test { public: Test(int a=0) { Test::a = a; } Test& operator ++ (); Test operator ++ (int); public: int a; }; Test& Test::operator ++ ()// qian di zeng { this->a++; return *this; } Test Test::operator ++ (int)// hou di zeng { Test rtemp(*this);// zhe li hui tiao yong kao bei gou zao han shu jin xing dui xiang de fu zhi gong zuo this->a++; return rtemp; } int main() { Test a(100); ++(++a); cout<<a.a<<endl; cout<<" guan cha hou di zeng qing kuang xia lin shi cun chu dui xiang de zhi zhuang tai :"<<(a++).a<<endl;// zhe li zheng shi ti xian hou di zeng cao zuo xian fan hui yuan you dui xiang zhi di fang cout<<a.a<<endl; (a++)++; cout<<a.a<<endl;// you yu hou di zeng shi zhi fan hui zhuang tai , suo yi (a++)++ zhi dui a zuo le yi ci di zeng cao zuo , cao zuo hou wei 104 er fei 105。 system("pause"); }   tong guo dui qian hou di zeng yun suan de fen xi , wo men ke yi jin yi bu ke yi le jie dao , dui yu xiang tong qing kuang de dan mu yun suan fu chong zai wo men dou bi xu zuo hao zhe xie qu bie gong zuo , bao zheng chong zai hou de yun suan fu fu he yao qiu 。 [url=http://www.wangchao.net.cn/bbs/pydetail_1785324.html][img]http://image.wangchao.net.cn/it/1323423872588.gif[/img][/url] geng duo nei rong qing kan C/C++ ji shu zhuan ti zhuan ti , huo
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
玉美人_珠联璧合
清纯美女米卡
清新靓丽的早晨
玲子的自信与性感
痞子的甘南日记
疑是银河落九天
雪域坝上四——纯美色
冬日恋歌——西城杨柳弄轻柔
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有