Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- // bez =int
- template <typename typ>
- struct Gruszka
- {
- // brakuje () i.e. operator () (args..)
- void operator ()(const typ x) const
- {
- cout << 2*x << endl;
- }
- };
- int main()
- {
- vector <int> myVec;
- myVec.push_back(5);
- myVec.push_back(12);
- myVec.push_back(521);
- myVec.push_back(9);
- vector <int>::iterator it;
- for(it = myVec.begin(); it!= myVec.end();it++)
- {
- cout << *it << endl;
- }
- for_each(myVec.begin(),myVec.end(),Gruszka <int>());
- // ^int
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement