Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // functor_demo.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <string>
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <functional>
- using namespace std;
- class Student {
- public:
- string firstName;
- string lastName;
- void show() { cout << firstName << " " << lastName << endl; }
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- vector<Student> Grp(3);
- Grp[0].firstName="A";
- Grp[1].firstName="B";
- Grp[2].firstName="C";
- Grp[0].lastName="A";
- Grp[1].lastName="B";
- Grp[2].lastName="C";
- for_each(Grp.begin(),Grp.end(),
- mem_fun_ref(&Student::show));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement