Posted by Anonymous Wed 14th Mar 2007 09:33 - Syntax is C++ - 33 views
Modification of posting from Anonymous Wed 14th Mar 2007 09:32
Download | New Post | Modify | Diff | Hide line numbers
  1. #include
  2. #include
  3. #include
  4. #include
  5.  
  6. typedef boost::signal()> MySignal;
  7.  
  8. class Test : public boost::signals::trackable {
  9. public:
  10.     Test(const std::string &s, MySignal & sgn);
  11.     void mySlot();
  12. private:
  13.     std::string str;
  14. };
  15.  
  16.  
  17. Test::Test(const std::string &s, MySignal & sgn) {
  18.     str = s;
  19.     sgn.connect(boost::bind(&Test::mySlot, this));
  20. }
  21.  
  22. void Test::mySlot() {
  23.     std::cerr << str << std::endl;
  24. }
  25.  
  26. int main() {
  27.     MySignal mySgn;
  28.     std::cerr << "create A" << std::endl;
  29.     Test *A = new Test("A", mySgn);
  30.     std::cerr << "fire SGN" << std::endl;
  31.     mySgn();
  32.     std::cerr << "create B" << std::endl;
  33.     Test *B = new Test("B", mySgn);
  34.     std::cerr << "fire SGN" << std::endl;
  35.     mySgn();
  36.     std::cerr << "delete A" << std::endl;
  37.     delete A;
  38.     std::cerr << "fire SGN" << std::endl;
  39.     mySgn();
  40.     std::cerr << "delete B" << std::endl;
  41.     delete B;
  42.     std::cerr << "fire SGN" << std::endl;
  43.     mySgn();
  44.  
  45.     std::cerr << "exit" << std::endl;
  46. }

PermaLink to this entry https://pastebin.co.uk/11855
Posted by Anonymous Wed 14th Mar 2007 09:33 - Syntax is C++ - 33 views
Modification of posting from Anonymous Wed 14th Mar 2007 09:32
Download | New Post | Modify | Diff | Hide line numbers

 

Comments: 0