How to declare an iterator for unknown STL container? for example, I want to write a function that recieve container and print it all using iterators:
template <class Container> void print(Container c) {
// how to declare iterator???????
my_iterator = c.begin();
while(my_iterator!=c.end()) {
cout << *my_iterator << endl;
my_iterator++;
}
}
auto it = c.begin();constreference, to avoid making an unnecessary copy.