views:

123

answers:

1

full disclosure - this is for a homework assignment. And I normally would not ask for homework help, but here it is.

I'm asked to provide 5 examples of "overloading implicit in c++". I'm sure he is referring to operator overloading for types such as char, int, float, etc in iostream and the types themselves.

I understand explicitly overloading an operators such as (my dumb example)

class Vegetables {
    public:
        Vegetables();
        ~Vegetables();
        Vegetables& operator+ (Vegetables&);
        Vegetables& operator- (Vegetables&);
    private:
        int beans;
        ... // more veggies here
};

Vegetables& Vegetables::operator+ (Veggies&) {
    beans += Veggies.beans;
    ...
    return *this;
}

So I am just trying to decide if he is referring to the overloading that is "implicit" when adding types. For example, int+double. I think what actually occurs is int gets cast as a double, then the double + operator is used and a double is returned? Of course, the way this happens varies based on if it is a value assignment or in iostream or other i/o method, etc. But my point remains...

+4  A: 
Mr.Ree
+1 for epic response.
Val
Thanks for the encouragement Val! I was debating whether to even post it or not!
Mr.Ree