Is there a better way of printing a vector in reverse order then this:
#include #include #include using namespace
Use reverse_iterator instead of iterator
reverse_iterator
iterator
int main() { int ia[4]={1, 2, 3, 4}; vector vec(ia,ia+4); for(vector::reverse_iterator it = vec.rbegin; it != vec.rend(); ++it) { std::cout << *it << std::endl; } }
The output will be: 4, 3, 2, 1