What I tried to do:

```
template <class T>
ostream& operator<<(ostream& ou, map<T,T> x) {
    for(typename map<T,T>::iterator it = x.begin(); it != x.end(); it++) {
        ou << it->first << ": " << it->second << endl;
    }
    return ou;
}

```

I tested it in the main:

```
int main() {
    map<char, int> m;
    m['a']++;
    m['b']++;
    m['c']++;
    m['d']++;

    cout << m << endl;
}

```

I then got the error:

> 
> 'error: no match for 'operator<<' in 'std::cout << m'
> 
> 
> 

The overloaded operator would work if I changed the function argument from `map<T,T>` to `map<char,int>`. Is there a minor issue in my code or is there a completely different way to do this? How would one go about overloading an operator for a container type in general using a template class?