Posted by Anonymous Wed 14th Mar 2007 09:32 - Syntax is None/text - 17 views
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. Test::Test(const std::string &s, MySignal & sgn) {
  17.     str = s;
  18.     sgn.connect(boost::bind(&Test::mySlot, this));
  19. }
  20.  
  21. void Test::mySlot() {
  22.     std::cerr << str << std::endl;
  23. }
  24.  
  25. int main() {
  26.     MySignal mySgn;
  27.     std::cerr << "create A" << std::endl;
  28.     Test *A = new Test("A", mySgn);
  29.     std::cerr << "fire SGN" << std::endl;
  30.     mySgn();
  31.     std::cerr << "create B" << std::endl;
  32.     Test *B = new Test("B", mySgn);
  33.     std::cerr << "fire SGN" << std::endl;
  34.     mySgn();
  35.     std::cerr << "delete A" << std::endl;
  36.     delete A;
  37.     std::cerr << "fire SGN" << std::endl;
  38.     mySgn();
  39.     std::cerr << "delete B" << std::endl;
  40.     delete B;
  41.     std::cerr << "fire SGN" << std::endl;
  42.     mySgn();
  43.  
  44.     std::cerr << "exit" << std::endl;
  45. }

PermaLink to this entry https://pastebin.co.uk/11854

The following amendments have been posted:

  1. Anonymous (Wed 14th Mar 2007 09:35)
  2. Anonymous (Wed 14th Mar 2007 09:33)
Posted by Anonymous Wed 14th Mar 2007 09:32 - Syntax is None/text - 17 views
Download | New Post | Modify | Diff | Hide line numbers

 

Comments: 0