青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

我輩豈是蓬蒿人!

C++ && keyWordSpotting

  C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
  11 Posts :: 0 Stories :: 4 Comments :: 0 Trackbacks

常用鏈接

留言簿(9)

我參與的團隊

搜索

  •  

積分與排名

  • 積分 - 7323
  • 排名 - 1369

最新評論

閱讀排行榜

評論排行榜

Thinking in C++, 2nd ed. Volume 1

?2000 by Bruce Eckel

Unary operators

The following example shows the syntax to overload all the unary operators, in the form of both global functions (non-member friend functions) and as member functions. These will expand upon the Integer class shown previously and add a new byte class. The meaning of your particular operators will depend on the way you want to use them, but consider the client programmer before doing something unexpected.

Here is a catalog of all the unary functions:


??1?//:?C12:OverloadingUnaryOperators.cpp
??2?#include?<iostream>
??3?using?namespace?std;
??4?
??5?//?Non-member?functions:
??6?class?Integer?{
??7???long?i;
??8???Integer*?This()?{?return?this;?}
??9?public:
?10???Integer(long?ll?=?0)?:?i(ll)?{}
?11???//?No?side?effects?takes?const&?argument:
?12???friend?const?Integer&
?13?????operator+(const?Integer&?a);
?14???friend?const?Integer
?15?????operator-(const?Integer&?a);
?16???friend?const?Integer
?17?????operator~(const?Integer&?a);
?18???friend?Integer*
?19?????operator&(Integer&?a);
?20???friend?int
?21?????operator!(const?Integer&?a);
?22???//?Side?effects?have?non-const&?argument:
?23???//?Prefix:
?24???friend?const?Integer&
?25?????operator++(Integer&?a);
?26???//?Postfix:
?27???friend?const?Integer
?28?????operator++(Integer&?a,?int);
?29???//?Prefix:
?30???friend?const?Integer&
?31?????operator--(Integer&?a);
?32???//?Postfix:
?33???friend?const?Integer
?34?????operator--(Integer&?a,?int);
?35?};
?36?
?37?//?Global?operators:
?38?const?Integer&?operator+(const?Integer&?a)?{
?39???cout?<<?"+Integer\n";
?40???return?a;?//?Unary?+?has?no?effect
?41?}
?42?const?Integer?operator-(const?Integer&?a)?{
?43???cout?<<?"-Integer\n";
?44???return?Integer(-a.i);
?45?}
?46?const?Integer?operator~(const?Integer&?a)?{
?47???cout?<<?"~Integer\n";
?48???return?Integer(~a.i);
?49?}
?50?Integer*?operator&(Integer&?a)?{
?51???cout?<<?"&Integer\n";
?52???return?a.This();?//?&a?is?recursive!
?53?}
?54?int?operator!(const?Integer&?a)?{
?55???cout?<<?"!Integer\n";
?56???return?!a.i;
?57?}
?58?//?Prefix;?return?incremented?value
?59?const?Integer&?operator++(Integer&?a)?{
?60???cout?<<?"++Integer\n";
?61???a.i++;
?62???return?a;
?63?}
?64?//?Postfix;?return?the?value?before?increment:
?65?const?Integer?operator++(Integer&?a,?int)?{
?66???cout?<<?"Integer++\n";
?67???Integer?before(a.i);
?68???a.i++;
?69???return?before;
?70?}
?71?//?Prefix;?return?decremented?value
?72?const?Integer&?operator--(Integer&?a)?{
?73???cout?<<?"--Integer\n";
?74???a.i--;
?75???return?a;
?76?}
?77?//?Postfix;?return?the?value?before?decrement:
?78?const?Integer?operator--(Integer&?a,?int)?{
?79???cout?<<?"Integer--\n";
?80???Integer?before(a.i);
?81???a.i--;
?82???return?before;
?83?}
?84?
?85?//?Show?that?the?overloaded?operators?work:
?86?void?f(Integer?a)?{
?87???+a;
?88???-a;
?89???~a;
?90???Integer*?ip?=?&a;
?91???!a;
?92???++a;
?93???a++;
?94???--a;
?95???a--;
?96?}
?97?
?98?//?Member?functions?(implicit?"this"):
?99?class?Byte?{
100???unsigned?char?b;
101?public:
102???Byte(unsigned?char?bb?=?0)?:?b(bb)?{}
103???//?No?side?effects:?const?member?function:
104???const?Byte&?operator+()?const?{
105?????cout?<<?"+Byte\n";
106?????return?*this;
107???}
108???const?Byte?operator-()?const?{
109?????cout?<<?"-Byte\n";
110?????return?Byte(-b);
111???}
112???const?Byte?operator~()?const?{
113?????cout?<<?"~Byte\n";
114?????return?Byte(~b);
115???}
116???Byte?operator!()?const?{
117?????cout?<<?"!Byte\n";
118?????return?Byte(!b);
119???}
120???Byte*?operator&()?{
121?????cout?<<?"&Byte\n";
122?????return?this;
123???}
124???//?Side?effects:?non-const?member?function:
125???const?Byte&?operator++()?{?//?Prefix
126?????cout?<<?"++Byte\n";
127?????b++;
128?????return?*this;
129???}
130???const?Byte?operator++(int)?{?//?Postfix
131?????cout?<<?"Byte++\n";
132?????Byte?before(b);
133?????b++;
134?????return?before;
135???}
136???const?Byte&?operator--()?{?//?Prefix
137?????cout?<<?"--Byte\n";
138?????--b;
139?????return?*this;
140???}
141???const?Byte?operator--(int)?{?//?Postfix
142?????cout?<<?"Byte--\n";
143?????Byte?before(b);
144?????--b;
145?????return?before;
146???}
147?};
148?
149?void?g(Byte?b)?{
150???+b;
151???-b;
152???~b;
153???Byte*?bp?=?&b;
154???!b;
155???++b;
156???b++;
157???--b;
158???b--;
159?}
160?
161?int?main()?{
162???Integer?a;
163???f(a);
164???Byte?b;
165???g(b);
166?}?///:~
167?

The functions are grouped according to the way their arguments are passed. Guidelines for how to pass and return arguments are given later. The forms above (and the ones that follow in the next section) are typically what you’ll use, so start with them as a pattern when overloading your own operators.

Binary operators

The following listing repeats the example of OverloadingUnaryOperators.cpp for binary operators so you have an example of all the operators you might want to overload. Again, both global versions and member function versions are shown.

??1?//:?C12:Integer.h
??2?//?Non-member?overloaded?operators
??3?#ifndef?INTEGER_H
??4?#define?INTEGER_H
??5?#include?<iostream>
??6?
??7?//?Non-member?functions:
??8?class?Integer?{?
??9???long?i;
?10?public:
?11???Integer(long?ll?=?0)?:?i(ll)?{}
?12???//?Operators?that?create?new,?modified?value:
?13???friend?const?Integer
?14?????operator+(const?Integer&?left,
?15???????????????const?Integer&?right);
?16???friend?const?Integer
?17?????operator-(const?Integer&?left,
?18???????????????const?Integer&?right);
?19???friend?const?Integer
?20?????operator*(const?Integer&?left,
?21???????????????const?Integer&?right);
?22???friend?const?Integer
?23?????operator/(const?Integer&?left,
?24???????????????const?Integer&?right);
?25???friend?const?Integer
?26?????operator%(const?Integer&?left,
?27???????????????const?Integer&?right);
?28???friend?const?Integer
?29?????operator^(const?Integer&?left,
?30???????????????const?Integer&?right);
?31???friend?const?Integer
?32?????operator&(const?Integer&?left,
?33???????????????const?Integer&?right);
?34???friend?const?Integer
?35?????operator|(const?Integer&?left,
?36???????????????const?Integer&?right);
?37???friend?const?Integer
?38?????operator<<(const?Integer&?left,
?39????????????????const?Integer&?right);
?40???friend?const?Integer
?41?????operator>>(const?Integer&?left,
?42????????????????const?Integer&?right);
?43???//?Assignments?modify?&?return?lvalue:
?44???friend?Integer&
?45?????operator+=(Integer&?left,
?46????????????????const?Integer&?right);
?47???friend?Integer&
?48?????operator-=(Integer&?left,
?49????????????????const?Integer&?right);
?50???friend?Integer&
?51?????operator*=(Integer&?left,
?52????????????????const?Integer&?right);
?53???friend?Integer&
?54?????operator/=(Integer&?left,
?55????????????????const?Integer&?right);
?56???friend?Integer&
?57?????operator%=(Integer&?left,
?58????????????????const?Integer&?right);
?59???friend?Integer&
?60?????operator^=(Integer&?left,
?61????????????????const?Integer&?right);
?62???friend?Integer&
?63?????operator&=(Integer&?left,
?64????????????????const?Integer&?right);
?65???friend?Integer&
?66?????operator|=(Integer&?left,
?67????????????????const?Integer&?right);
?68???friend?Integer&
?69?????operator>>=(Integer&?left,
?70?????????????????const?Integer&?right);
?71???friend?Integer&
?72?????operator<<=(Integer&?left,
?73?????????????????const?Integer&?right);
?74???//?Conditional?operators?return?true/false:
?75???friend?int
?76?????operator==(const?Integer&?left,
?77????????????????const?Integer&?right);
?78???friend?int
?79?????operator!=(const?Integer&?left,
?80????????????????const?Integer&?right);
?81???friend?int
?82?????operator<(const?Integer&?left,
?83???????????????const?Integer&?right);
?84???friend?int
?85?????operator>(const?Integer&?left,
?86???????????????const?Integer&?right);
?87???friend?int
?88?????operator<=(const?Integer&?left,
?89????????????????const?Integer&?right);
?90???friend?int
?91?????operator>=(const?Integer&?left,
?92????????????????const?Integer&?right);
?93???friend?int
?94?????operator&&(const?Integer&?left,
?95????????????????const?Integer&?right);
?96???friend?int
?97?????operator||(const?Integer&?left,
?98????????????????const?Integer&?right);
?99???//?Write?the?contents?to?an?ostream:
100???void?print(std::ostream&?os)?const?{?os?<<?i;?}
101?};?
102?#endif?//?INTEGER_H?///:~
103?//:?C12:Integer.cpp?{O}
104?//?Implementation?of?overloaded?operators
105?#include?"Integer.h"
106?#include?"../require.h"
107?
108?const?Integer
109???operator+(const?Integer&?left,
110?????????????const?Integer&?right)?{
111???return?Integer(left.i?+?right.i);
112?}
113?const?Integer
114???operator-(const?Integer&?left,
115?????????????const?Integer&?right)?{
116???return?Integer(left.i?-?right.i);
117?}
118?const?Integer
119???operator*(const?Integer&?left,
120?????????????const?Integer&?right)?{
121???return?Integer(left.i?*?right.i);
122?}
123?const?Integer
124???operator/(const?Integer&?left,
125?????????????const?Integer&?right)?{
126???require(right.i?!=?0,?"divide?by?zero");
127???return?Integer(left.i?/?right.i);
128?}
129?const?Integer
130???operator%(const?Integer&?left,
131?????????????const?Integer&?right)?{
132???require(right.i?!=?0,?"modulo?by?zero");
133???return?Integer(left.i?%?right.i);
134?}
135?const?Integer
136???operator^(const?Integer&?left,
137?????????????const?Integer&?right)?{
138???return?Integer(left.i?^?right.i);
139?}
140?const?Integer
141???operator&(const?Integer&?left,
142?????????????const?Integer&?right)?{
143???return?Integer(left.i?&?right.i);
144?}
145?const?Integer
146???operator|(const?Integer&?left,
147?????????????const?Integer&?right)?{
148???return?Integer(left.i?|?right.i);
149?}
150?const?Integer
151???operator<<(const?Integer&?left,
152??????????????const?Integer&?right)?{
153???return?Integer(left.i?<<?right.i);
154?}
155?const?Integer
156???operator>>(const?Integer&?left,
157??????????????const?Integer&?right)?{
158???return?Integer(left.i?>>?right.i);
159?}
160?//?Assignments?modify?&?return?lvalue:
161?Integer&?operator+=(Integer&?left,
162?????????????????????const?Integer&?right)?{
163????if(&left?==?&right)?{/*?self-assignment?*/}
164????left.i?+=?right.i;
165????return?left;
166?}
167?Integer&?operator-=(Integer&?left,
168?????????????????????const?Integer&?right)?{
169????if(&left?==?&right)?{/*?self-assignment?*/}
170????left.i?-=?right.i;
171????return?left;
172?}
173?Integer&?operator*=(Integer&?left,
174?????????????????????const?Integer&?right)?{
175????if(&left?==?&right)?{/*?self-assignment?*/}
176????left.i?*=?right.i;
177????return?left;
178?}
179?Integer&?operator/=(Integer&?left,
180?????????????????????const?Integer&?right)?{
181????require(right.i?!=?0,?"divide?by?zero");
182????if(&left?==?&right)?{/*?self-assignment?*/}
183????left.i?/=?right.i;
184????return?left;
185?}
186?Integer&?operator%=(Integer&?left,
187?????????????????????const?Integer&?right)?{
188????require(right.i?!=?0,?"modulo?by?zero");
189????if(&left?==?&right)?{/*?self-assignment?*/}
190????left.i?%=?right.i;
191????return?left;
192?}
193?Integer&?operator^=(Integer&?left,
194?????????????????????const?Integer&?right)?{
195????if(&left?==?&right)?{/*?self-assignment?*/}
196????left.i?^=?right.i;
197????return?left;
198?}
199?Integer&?operator&=(Integer&?left,
200?????????????????????const?Integer&?right)?{
201????if(&left?==?&right)?{/*?self-assignment?*/}
202????left.i?&=?right.i;
203????return?left;
204?}
205?Integer&?operator|=(Integer&?left,
206?????????????????????const?Integer&?right)?{
207????if(&left?==?&right)?{/*?self-assignment?*/}
208????left.i?|=?right.i;
209????return?left;
210?}
211?Integer&?operator>>=(Integer&?left,
212??????????????????????const?Integer&?right)?{
213????if(&left?==?&right)?{/*?self-assignment?*/}
214????left.i?>>=?right.i;
215????return?left;
216?}
217?Integer&?operator<<=(Integer&?left,
218??????????????????????const?Integer&?right)?{
219????if(&left?==?&right)?{/*?self-assignment?*/}
220????left.i?<<=?right.i;
221????return?left;
222?}
223?//?Conditional?operators?return?true/false:
224?int?operator==(const?Integer&?left,
225????????????????const?Integer&?right)?{
226?????return?left.i?==?right.i;
227?}
228?int?operator!=(const?Integer&?left,
229????????????????const?Integer&?right)?{
230?????return?left.i?!=?right.i;
231?}
232?int?operator<(const?Integer&?left,
233???????????????const?Integer&?right)?{
234?????return?left.i?<?right.i;
235?}
236?int?operator>(const?Integer&?left,
237???????????????const?Integer&?right)?{
238?????return?left.i?>?right.i;
239?}
240?int?operator<=(const?Integer&?left,
241????????????????const?Integer&?right)?{
242?????return?left.i?<=?right.i;
243?}
244?int?operator>=(const?Integer&?left,
245????????????????const?Integer&?right)?{
246?????return?left.i?>=?right.i;
247?}
248?int?operator&&(const?Integer&?left,
249????????????????const?Integer&?right)?{
250?????return?left.i?&&?right.i;
251?}
252?int?operator||(const?Integer&?left,
253????????????????const?Integer&?right)?{
254?????return?left.i?||?right.i;
255?}?///:~
256?//:?C12:IntegerTest.cpp
257?//{L}?Integer
258?#include?"Integer.h"
259?#include?<fstream>
260?using?namespace?std;
261?ofstream?out("IntegerTest.out");
262?
263?void?h(Integer&?c1,?Integer&?c2)?{
264???//?A?complex?expression:
265???c1?+=?c1?*?c2?+?c2?%?c1;
266???#define?TRY(OP)?\
267?????out?<<?"c1?=?";?c1.print(out);?\
268?????out?<<?",?c2?=?";?c2.print(out);?\
269?????out?<<?";??c1?"?#OP?"?c2?produces?";?\
270?????(c1?OP?c2).print(out);?\
271?????out?<<?endl;
272???TRY(+)?TRY(-)?TRY(*)?TRY(/)
273???TRY(%)?TRY(^)?TRY(&)?TRY(|)
274???TRY(<<)?TRY(>>)?TRY(+=)?TRY(-=)
275???TRY(*=)?TRY(/=)?TRY(%=)?TRY(^=)
276???TRY(&=)?TRY(|=)?TRY(>>=)?TRY(<<=)
277???//?Conditionals:
278???#define?TRYC(OP)?\
279?????out?<<?"c1?=?";?c1.print(out);?\
280?????out?<<?",?c2?=?";?c2.print(out);?\
281?????out?<<?";??c1?"?#OP?"?c2?produces?";?\
282?????out?<<?(c1?OP?c2);?\
283?????out?<<?endl;
284???TRYC(<)?TRYC(>)?TRYC(==)?TRYC(!=)?TRYC(<=)
285???TRYC(>=)?TRYC(&&)?TRYC(||)
286?}?
287?
288?int?main()?{
289???cout?<<?"friend?functions"?<<?endl;
290???Integer?c1(47),?c2(9);
291???h(c1,?c2);
292?}?///:~
293?//:?C12:Byte.h
294?//?Member?overloaded?operators
295?#ifndef?BYTE_H
296?#define?BYTE_H
297?#include?"../require.h"
298?#include?<iostream>
299?//?Member?functions?(implicit?"this"):
300?class?Byte?{?
301???unsigned?char?b;
302?public:
303???Byte(unsigned?char?bb?=?0)?:?b(bb)?{}
304???//?No?side?effects:?const?member?function:
305???const?Byte
306?????operator+(const?Byte&?right)?const?{
307?????return?Byte(b?+?right.b);
308???}
309???const?Byte
310?????operator-(const?Byte&?right)?const?{
311?????return?Byte(b?-?right.b);
312???}
313???const?Byte
314?????operator*(const?Byte&?right)?const?{
315?????return?Byte(b?*?right.b);
316???}
317???const?Byte
318?????operator/(const?Byte&?right)?const?{
319?????require(right.b?!=?0,?"divide?by?zero");
320?????return?Byte(b?/?right.b);
321???}
322???const?Byte
323?????operator%(const?Byte&?right)?const?{
324?????require(right.b?!=?0,?"modulo?by?zero");
325?????return?Byte(b?%?right.b);
326???}
327???const?Byte
328?????operator^(const?Byte&?right)?const?{
329?????return?Byte(b?^?right.b);
330???}
331???const?Byte
332?????operator&(const?Byte&?right)?const?{
333?????return?Byte(b?&?right.b);
334???}
335???const?Byte
336?????operator|(const?Byte&?right)?const?{
337?????return?Byte(b?|?right.b);
338???}
339???const?Byte
340?????operator<<(const?Byte&?right)?const?{
341?????return?Byte(b?<<?right.b);
342???}
343???const?Byte
344?????operator>>(const?Byte&?right)?const?{
345?????return?Byte(b?>>?right.b);
346???}
347???//?Assignments?modify?&?return?lvalue.
348???//?operator=?can?only?be?a?member?function:
349???Byte&?operator=(const?Byte&?right)?{
350?????//?Handle?self-assignment:
351?????if(this?==?&right)?return?*this;
352?????b?=?right.b;
353?????return?*this;
354???}
355???Byte&?operator+=(const?Byte&?right)?{
356?????if(this?==?&right)?{/*?self-assignment?*/}
357?????b?+=?right.b;
358?????return?*this;
359???}
360???Byte&?operator-=(const?Byte&?right)?{
361?????if(this?==?&right)?{/*?self-assignment?*/}
362?????b?-=?right.b;
363?????return?*this;
364???}
365???Byte&?operator*=(const?Byte&?right)?{
366?????if(this?==?&right)?{/*?self-assignment?*/}
367?????b?*=?right.b;
368?????return?*this;
369???}
370???Byte&?operator/=(const?Byte&?right)?{
371?????require(right.b?!=?0,?"divide?by?zero");
372?????if(this?==?&right)?{/*?self-assignment?*/}
373?????b?/=?right.b;
374?????return?*this;
375???}
376???Byte&?operator%=(const?Byte&?right)?{
377?????require(right.b?!=?0,?"modulo?by?zero");
378?????if(this?==?&right)?{/*?self-assignment?*/}
379?????b?%=?right.b;
380?????return?*this;
381???}
382???Byte&?operator^=(const?Byte&?right)?{
383?????if(this?==?&right)?{/*?self-assignment?*/}
384?????b?^=?right.b;
385?????return?*this;
386???}
387???Byte&?operator&=(const?Byte&?right)?{
388?????if(this?==?&right)?{/*?self-assignment?*/}
389?????b?&=?right.b;
390?????return?*this;
391???}
392???Byte&?operator|=(const?Byte&?right)?{
393?????if(this?==?&right)?{/*?self-assignment?*/}
394?????b?|=?right.b;
395?????return?*this;
396???}
397???Byte&?operator>>=(const?Byte&?right)?{
398?????if(this?==?&right)?{/*?self-assignment?*/}
399?????b?>>=?right.b;
400?????return?*this;
401???}
402???Byte&?operator<<=(const?Byte&?right)?{
403?????if(this?==?&right)?{/*?self-assignment?*/}
404?????b?<<=?right.b;
405?????return?*this;
406???}
407???//?Conditional?operators?return?true/false:
408???int?operator==(const?Byte&?right)?const?{
409???????return?b?==?right.b;
410???}
411???int?operator!=(const?Byte&?right)?const?{
412???????return?b?!=?right.b;
413???}
414???int?operator<(const?Byte&?right)?const?{
415???????return?b?<?right.b;
416???}
417???int?operator>(const?Byte&?right)?const?{
418???????return?b?>?right.b;
419???}
420???int?operator<=(const?Byte&?right)?const?{
421???????return?b?<=?right.b;
422???}
423???int?operator>=(const?Byte&?right)?const?{
424???????return?b?>=?right.b;
425???}
426???int?operator&&(const?Byte&?right)?const?{
427???????return?b?&&?right.b;
428???}
429???int?operator||(const?Byte&?right)?const?{
430???????return?b?||?right.b;
431???}
432???//?Write?the?contents?to?an?ostream:
433???void?print(std::ostream&?os)?const?{
434?????os?<<?"0x"?<<?std::hex?<<?int(b)?<<?std::dec;
435???}
436?};?
437?#endif?//?BYTE_H?///:~
438?//:?C12:ByteTest.cpp
439?#include?"Byte.h"
440?#include?<fstream>
441?using?namespace?std;
442?ofstream?out("ByteTest.out");
443?
444?void?k(Byte&?b1,?Byte&?b2)?{
445???b1?=?b1?*?b2?+?b2?%?b1;
446?
447???#define?TRY2(OP)?\
448?????out?<<?"b1?=?";?b1.print(out);?\
449?????out?<<?",?b2?=?";?b2.print(out);?\
450?????out?<<?";??b1?"?#OP?"?b2?produces?";?\
451?????(b1?OP?b2).print(out);?\
452?????out?<<?endl;
453?
454???b1?=?9;?b2?=?47;
455???TRY2(+)?TRY2(-)?TRY2(*)?TRY2(/)
456???TRY2(%)?TRY2(^)?TRY2(&)?TRY2(|)
457???TRY2(<<)?TRY2(>>)?TRY2(+=)?TRY2(-=)
458???TRY2(*=)?TRY2(/=)?TRY2(%=)?TRY2(^=)
459???TRY2(&=)?TRY2(|=)?TRY2(>>=)?TRY2(<<=)
460???TRY2(=)?//?Assignment?operator
461?
462???//?Conditionals:
463???#define?TRYC2(OP)?\
464?????out?<<?"b1?=?";?b1.print(out);?\
465?????out?<<?",?b2?=?";?b2.print(out);?\
466?????out?<<?";??b1?"?#OP?"?b2?produces?";?\
467?????out?<<?(b1?OP?b2);?\
468?????out?<<?endl;
469?
470???b1?=?9;?b2?=?47;
471???TRYC2(<)?TRYC2(>)?TRYC2(==)?TRYC2(!=)?TRYC2(<=)
472???TRYC2(>=)?TRYC2(&&)?TRYC2(||)
473?
474???//?Chained?assignment:
475???Byte?b3?=?92;
476???b1?=?b2?=?b3;
477?}
478?
479?int?main()?{
480???out?<<?"member?functions:"?<<?endl;
481???Byte?b1(47),?b2(9);
482???k(b1,?b2);
483?}?///:~
484?

You can see that operator= is only allowed to be a member function. This is explained later.

Notice that all of the assignment operators have code to check for self-assignment; this is a general guideline. In some cases this is not necessary; for example, with operator+= you often want to say A+=A and have it add A to itself. The most important place to check for self-assignment is operator= because with complicated objects disastrous results may occur. (In some cases it’s OK, but you should always keep it in mind when writing operator=.)

All of the operators shown in the previous two examples are overloaded to handle a single type. It’s also possible to overload operators to handle mixed types, so you can add apples to oranges, for example. Before you start on an exhaustive overloading of operators, however, you should look at the section on automatic type conversion later in this chapter. Often, a type conversion in the right place can save you a lot of overloaded operators.

posted on 2006-08-17 12:14 keyws 閱讀(627) 評論(0)  編輯 收藏 引用 所屬分類: std C++ topic

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久久久久午夜| 久久久国产亚洲精品| 欧美国产高潮xxxx1819| 久久九九精品| 欧美二区在线看| 欧美成人精品三级在线观看| 欧美在线免费| 久久久久久久国产| 欧美成人嫩草网站| 亚洲美女区一区| 午夜精品久久久久久久99樱桃 | 亚洲一区二区三区四区五区午夜| 亚洲天堂av图片| 久久精品国产一区二区三区免费看| 久久久久亚洲综合| 亚洲二区三区四区| 亚洲欧洲日韩综合二区| 一区二区三区国产盗摄| 欧美在线播放一区| 欧美激情一区二区三区高清视频| 国产精品www网站| 在线观看国产精品网站| 在线视频中文亚洲| 久久久蜜桃一区二区人| 最新日韩欧美| 久久久7777| 国产精品久久久久aaaa| 亚洲高清在线观看一区| 亚洲免费在线看| 欧美寡妇偷汉性猛交| 亚洲午夜国产成人av电影男同| 欧美专区福利在线| 欧美日韩一区国产| 亚洲国产婷婷综合在线精品 | 欧美不卡高清| 亚洲无线一线二线三线区别av| 久久一日本道色综合久久| 欧美日韩精品免费在线观看视频| 国产一区二区三区四区老人| 99这里只有精品| 欧美成人一区二区| 欧美一区二区三区久久精品茉莉花| 欧美日韩成人综合天天影院| 在线成人小视频| 久久久久综合一区二区三区| 亚洲午夜一区二区| 欧美日韩亚洲视频| 亚洲精品美女在线观看播放| 久久影院亚洲| 欧美在线看片| 国内精品久久久久影院 日本资源| 亚洲视频在线观看免费| 亚洲国产欧美一区二区三区丁香婷| 久久精品官网| 激情综合视频| 猛男gaygay欧美视频| 久久九九国产| 亚洲欧美日本国产专区一区| 欧美视频日韩视频| 亚洲视频一区二区免费在线观看| 亚洲国产精品久久久久秋霞蜜臀 | 久久精品国产一区二区三区免费看 | 亚洲国产成人av| 久久久国产精品一区| 午夜精品免费| 国产一区日韩欧美| 久久综合福利| 欧美jizzhd精品欧美巨大免费| 亚洲激情亚洲| 亚洲精品视频在线看| 欧美色123| 欧美一级大片在线免费观看| 亚洲欧美日韩另类| 国内成+人亚洲+欧美+综合在线| 久久久久久伊人| 噜噜噜噜噜久久久久久91| 亚洲国产第一页| 99国产精品国产精品久久 | 欧美日韩视频| 欧美在线视频一区二区| 久久成人精品一区二区三区| 亚洲福利视频免费观看| 亚洲日韩中文字幕在线播放| 欧美午夜一区二区三区免费大片| 欧美一区二区三区日韩| 久久国产精品久久久久久电车 | 欧美婷婷在线| 久久精品国产99国产精品澳门| 久久久综合香蕉尹人综合网| 亚洲精品一区二区三区不| 99国产精品久久久| 韩国一区二区三区美女美女秀| 亚洲第一天堂av| 国产精品久久久久久久久果冻传媒 | 国内精品免费午夜毛片| 欧美成人国产一区二区| 欧美午夜不卡在线观看免费| 久久裸体视频| 欧美性大战久久久久久久| 久久人人97超碰国产公开结果| 欧美激情二区三区| 久久美女性网| 国产精品毛片a∨一区二区三区|国 | 久久综合给合久久狠狠色 | 亚洲一区二区精品在线| 久久av一区二区三区漫画| 亚洲精品久久久久久久久| 亚洲女同精品视频| 亚洲精品美女| 久久三级视频| 欧美一区二区高清在线观看| 免费成人高清在线视频| 久久成人免费视频| 欧美日韩国产bt| 男同欧美伦乱| 国产一区二区毛片| 国产精品99久久99久久久二8 | 国产精品嫩草久久久久| 欧美www在线| 国产精品天天摸av网| 亚洲激情另类| 黄色成人免费网站| 亚洲一区二区成人| 一本色道88久久加勒比精品 | 99国产精品国产精品久久| 在线电影国产精品| 久久激情综合网| 欧美在线一二三区| 欧美人与性动交cc0o| 久久在线91| 国产亚洲一区在线播放| 一本到12不卡视频在线dvd| 亚洲国产欧洲综合997久久| 久久成人在线| 麻豆9191精品国产| 激情成人中文字幕| 欧美在线高清| 久久久人成影片一区二区三区| 国产精品男女猛烈高潮激情| 一区二区三区国产精品| 一区二区三区高清不卡| 欧美日韩久久不卡| 亚洲精选大片| 亚洲欧美国产视频| 欧美少妇一区二区| av成人免费观看| 午夜欧美不卡精品aaaaa| 国产精品欧美一区二区三区奶水 | 免费在线国产精品| 欧美福利精品| 亚洲乱码国产乱码精品精天堂 | 亚洲毛片一区| 亚洲自拍高清| 国产模特精品视频久久久久 | 国产精品v日韩精品v欧美精品网站 | 在线精品观看| 久久影音先锋| 亚洲黄色毛片| 亚洲一区二区欧美| 国产精品丝袜久久久久久app| 亚洲男女自偷自拍图片另类| 久久久久免费视频| 日韩视频国产视频| 国产精品v片在线观看不卡| 亚洲天堂男人| 久久躁狠狠躁夜夜爽| 亚洲国产欧美一区二区三区丁香婷| 欧美国产日韩精品| 亚洲一区bb| 亚洲电影在线| 欧美亚洲在线| 亚洲黄色免费| 国产精品麻豆va在线播放| 久久欧美肥婆一二区| 91久久久久久国产精品| 久久精品99国产精品| 久久久欧美一区二区| 亚洲精品一区二区三| 欧美亚洲一区二区三区| 亚洲黄色av一区| 国产日韩av高清| 欧美激情视频在线免费观看 欧美视频免费一 | 国产日韩欧美不卡| 美女91精品| 久久久久天天天天| 艳女tv在线观看国产一区| 国产午夜精品久久| 欧美日本亚洲视频| 欧美在线亚洲综合一区| 亚洲国内精品| 久久视频免费观看| 亚洲免费视频观看| 亚洲精品在线二区| 国内精品一区二区三区| 国产精品久久久一本精品| 裸体歌舞表演一区二区| 小黄鸭精品aⅴ导航网站入口| 最新成人在线| 欧美激情第五页| 久久精品在线免费观看|