O
Ook
This is a few ways I've seen to overload operator+. I can understand that
you would want to pass a reference to the function if you wanted to change
some of the data elements of the class, but in the first example it's being
passed as a constant. Is this done for performance purposes so that it
doesn't create a copy of the class and pass the copy to the function?
Why would you have it return a reference to the class as in example 1? I
would think that the third example would be what you want to do.
Class Zoot.....
Zoot& operator+ (const Zoot& zzz); passes read only reference to class
Zoot operator+ (Zoot zzz); // passes copy of clacc
Zoot operator+ (const Zoot& zzz); // returns class, not reference - is this
right?
you would want to pass a reference to the function if you wanted to change
some of the data elements of the class, but in the first example it's being
passed as a constant. Is this done for performance purposes so that it
doesn't create a copy of the class and pass the copy to the function?
Why would you have it return a reference to the class as in example 1? I
would think that the third example would be what you want to do.
Class Zoot.....
Zoot& operator+ (const Zoot& zzz); passes read only reference to class
Zoot operator+ (Zoot zzz); // passes copy of clacc
Zoot operator+ (const Zoot& zzz); // returns class, not reference - is this
right?