Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
binder
//g++ 4.9.3 #include <iostream> #include <functional> #include <vector> #include <string> #include <algorithm> using namespace std::placeholders; class Person { public: Person(const char* str): name(str){} void setName(const std::string& _name) { name = _name;} std::string getName() const { return name; } private: std::string name; }; std::string randomString(std::string str) { random_shuffle(str.begin(), str.end()); return str; } int main() { std::vector<Person> vPersons { {"Margaret"}, {"Charles"}, {"Karl"}, {"Stephen"}, {"George"}}; std::for_each(vPersons.begin(), vPersons.end(), [](Person& p){ std::cout << p.getName() << " "; }); std::cout << std::endl; for_each(vPersons.begin(), vPersons.end(), bind(&Person::setName, _1, bind(randomString, bind(&Person::getName, _1)))); std::for_each(vPersons.begin(), vPersons.end(), [](Person& p){ std::cout << p.getName() << " "; }); std::cout << std::endl; }
run
|
edit
|
history
|
help
0
hilbert
Web Browser History - DLL
Adress
a
FindMissingLagrange
volatile thread-safe object
Variadic template example
Test
PalindromePair-s1
pi with cmath