Oh okay. That makes sense. So, my user created classes; the compiler doesn't know how to add two user created classes, so I overload the operator+ to tell it exactly how?
Overloading an operator informs the compiler how it should handle user-defined types with different operators. For example, let's pretend you were a compiler, and I gave you this expression: x_ + y_, where x_ and y_ are of type Type:
1 2 3 4 5
struct Type
{
int i_;
double d_; // I just realised what I wrote :)
};
How would you, the compiler, perform the addition? You wouldn't know, would you? By overloading the addition operator, I'm able to tell you how you should handle Type addition. For instance:
1 2 3 4 5 6
Type operator + (Type const &l_, Type const &r_)
{
// OK, compiler, this is how you should handle it:
// [Statement];
// [Statement];
}
Now that you know how to handle Type addition, you follow my blueprints and be on your merry-way.