SHARE
TWEET

Untitled

a guest Jul 24th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top