Define a base Team class with virtual methods getHomeColor() and getAwayColor(). The comparison logic uses these methods without knowing the concrete team type.
Virtual methods enable runtime polymorphism. When you call team->getHomeColor() through a base pointer, the actual derived class's method runs. This means you can add new team types later without changing the comparison code.
For this problem in particular: loop through all pairs where . When hosts, check if teams[i].homeColor equals teams[j].awayColor. Count all matches. The nested loop gives you comparisons.