1) The return type.. could be int, void, double,string,etc. in this case the function will return a cOBJECT
cOBJECT cOBJECT :: operator + (const cOBJECT &r)
2) The class that this function belongs to.. in this case class cOBJECT
3) Binary scope resolution.. or something like that... tells the compiler that operator+() function is inside the class cOBJECT
4) The function name.. it could be called addNums.. it doesn't matter...
5) The variable being passed in... const means it cannot be modified in any way...
varthree = varone + vartwo;
varone is calling the function + and it is passing in the variable vartwo which corresponds to #5 above.
if the function were named addNums() instead of operator + in this case you would call it by varone.addNums(vartwo);
automatically get passed through this parameter when it's
added to varone?
just remember in order to invoke the + function :
leftside of + must be of type cOBJECT..
rightside of + must be of type cOBJECT..
both varone and vartwo are being passed into the function.. however.. inside the function to change a member of varone you just need to:
but for vartwo u must write:
hope this mess helps u out in some way..
cOBJECT operator + (const cOBJECT &)