Posted by Anonymous Wed 14th Mar 2007 09:35 - Syntax is C++ - 20 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.  
  12.     void operator()();
  13. private:
  14.     std::string str;
  15. };
  16.  
  17. Test::Test(const std::string &s, MySignal & sgn) {
  18.     str = s;
  19.     sgn.connect(*this);
  20. }
  21.  
  22. void Test::operator()() {
  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/11856
Posted by Anonymous Wed 14th Mar 2007 09:35 - Syntax is C++ - 20 views
Modification of posting from Anonymous Wed 14th Mar 2007 09:32
Download | New Post | Modify | Diff | Hide line numbers

 

Comments: 0