| 1 |
#include <iostream> |
| 2 |
#include <vector> |
| 3 |
#include <iterator> |
| 4 |
#include "foreach.h" |
| 5 |
using namespace std; |
| 6 |
|
| 7 |
class StringVector: public vector<string> |
| 8 |
{ |
| 9 |
public: |
| 10 |
StringVector(char **begin, char **end) |
| 11 |
: |
| 12 |
vector<string>(begin, end) |
| 13 |
{} |
| 14 |
void display(string const &str) const |
| 15 |
{ |
| 16 |
cout << str << " "; |
| 17 |
} |
| 18 |
}; |
| 19 |
|
| 20 |
int main(int argc, char **argv) |
| 21 |
{ |
| 22 |
StringVector vs{ argv, argv + argc }; |
| 23 |
|
| 24 |
ForEach(vs.begin(), vs.end(), vs, &StringVector::display); |
| 25 |
cout << '\n'; |
| 26 |
} |
| 27 |
/* |
| 28 |
Output generated when running a.out alpha bravo charley |
| 29 |
|
| 30 |
a.out alpha bravo charley |
| 31 |
*/ |