fork download
  1. #include <iostream>
  2. #include <new>
  3. #include <typeinfo>
  4. #include <string>
  5. #include <vector>
  6. #include <functional>
  7. #include <algorithm>
  8. using namespace std;
  9.  
  10. class A {
  11. public:
  12. A() {
  13. cout << "Calling A constructor" << endl;
  14. }
  15. int x=0;
  16. virtual void someshit() {
  17. cout << "Base class function" << endl;
  18. }
  19. };
  20.  
  21. class D : public A {
  22. public :
  23. virtual void someshit() {
  24. cout << "Derived class function" << endl;
  25. }
  26. };
  27.  
  28. int main() {
  29. function<bool (const string*)> fp = &string::empty;
  30. auto se=&string::empty;
  31. vector<string> v{"Hello", "xxx", ""};
  32. vector<string*> vs{{new string("Hello")}};
  33. for_each(vs.begin(), vs.end(), fp);
  34. return 0;
  35. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty