I've ran into some trouble while trying to solve a simple problem for my C++ class.
I have two classes: Component, an abstract class from which I inherit other classes and List, a class that has a list of Components (it is not a template class). I want to overload the operator+. so that when I "add" two components, it will return a List containing both Components.
I've done so using this, which shows no errors:
friend List operator +(Component &c1, Component &c2) {
        List l;
        l.push(c1);
        l.push(c2);
        return l;
    }
However, when I try to "add" two objects of classes that are inherited from Component, I get the following error:
no match for 'operator+' in 'c1 + c2'
Here is how I add the objects:
Inherited1 c1(1, 2, 3);
Inherited2 c2(1, 3.2, 10);
List l1 = c1+c2;
 
    