Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. class A
  2. {
  3. public:
  4.  
  5. A() : value(false) {}
  6.  
  7. bool get() const
  8. {
  9. return value;
  10. }
  11.  
  12. protected:
  13. bool value;
  14. };
  15.  
  16. class B : public A
  17. {
  18. public:
  19.  
  20. void set()
  21. {
  22. value = true;
  23. }
  24. };
  25.  
  26. B* b = new B;
  27. std::shared_ptr<A> a(b);
  28.  
  29. auto func = std::bind(&B::set, *b);
  30.  
  31. std::cout << a->get() << std::endl;
  32. func();
  33. std::cout << a->get() << std::endl;
  34.  
  35. auto func = std::bind(&B::set, std::ref(*b));
  36.  
  37. auto func = std::bind(&B::set, b);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement