Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <list>
- #include <algorithm>
- #include <iterator>
- class gen {
- public:
- gen() { _n = 0; }
- int operator()(){
- return --_n;
- }
- private:
- int _n;
- };
- class PRINT {
- public:
- void operator()(int &el){
- std::cout << el << ", ";
- }
- };
- int main() {
- std::list<int> col;
- std::generate_n (front_inserter(col), 9, gen());
- std::for_each(col.begin(), col.end(), PRINT());
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement