C++ Exercise for the Day
C++ exercise for the day. Write the header file (say "util.h"
) needed to define (not implement) operator<<
for a vector of integers. Basically, the following code should compile and work in all situations:
#include "util.h" // ... Some time later in a function or method ... { std::vector<int> v; v.push_back(1); v.push_back(2); v.push_back(3); std::cout << "My vector: " << v << std::endl; }
Maybe I'm just dumb, but it took me the better part of a whole day to figure out how to do this correctly. My guess is that if you aren't 100% sure of the answer, you will be surprised by it. Answer to come in a day or two.