I plan to write a function which can print all the data of any container. In other words, I can use with different containers type like vector, deque or list and that I can call
Using c++11 you can simplify it to:
template void print(const C &data){ for (auto &elem : data) cout << elem << " "; cout << endl; }
and call it with print(data). You could also use std::for_each or copy it directly into cout.
print(data)
std::for_each