I understand how polymorphism and inheritance works in C++, but my problem is: how do you make operators polymorphic for the following specific example?
Say I have a Foo class and two Foo instances, fooA and fooB. I want to redefine the plus sign operator so that “fooA + fooB;” does something specific to Foo instances (whatever that may be). How would the function prototype look? It’s confusing me because I’m used to functions starting with a letter… Any help would be greatly appreciated.
By the way, this isn’t a homework question — more like a wonderment (I was thinking about polymorphism in Ruby).
Example from http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/topic/com.ibm.xlcpp8a.doc/language/ref/cplr318.htm: