-
#include
-
#include
-
#include
-
#include
-
-
typedef boost::signal
MySignal; -
-
class Test : public boost::signals::trackable {
-
public:
-
Test(const std::string &s, MySignal & sgn);
-
void mySlot();
-
private:
-
std::string str;
-
};
-
-
Test::Test(const std::string &s, MySignal & sgn) {
-
str = s;
-
sgn.connect(boost::bind(&Test::mySlot, this));
-
}
-
-
void Test::mySlot() {
-
std::cerr << str << std::endl;
-
}
-
-
int main() {
-
MySignal mySgn;
-
std::cerr << "create A" << std::endl;
-
Test *A = new Test("A", mySgn);
-
std::cerr << "fire SGN" << std::endl;
-
mySgn();
-
std::cerr << "create B" << std::endl;
-
Test *B = new Test("B", mySgn);
-
std::cerr << "fire SGN" << std::endl;
-
mySgn();
-
std::cerr << "delete A" << std::endl;
-
delete A;
-
std::cerr << "fire SGN" << std::endl;
-
mySgn();
-
std::cerr << "delete B" << std::endl;
-
delete B;
-
std::cerr << "fire SGN" << std::endl;
-
mySgn();
-
-
std::cerr << "exit" << std::endl;
-
}
Posted by Anonymous Wed 14th Mar 2007 09:32 - Syntax is None/text - 17 views
Download | New Post | Modify | Diff | Hide line numbers
Download | New Post | Modify | Diff | Hide line numbers
PermaLink to this entry https://pastebin.co.uk/11854
The following amendments have been posted:
Posted by Anonymous Wed 14th Mar 2007 09:32 - Syntax is None/text - 17 views
Download | New Post | Modify | Diff | Hide line numbers
Download | New Post | Modify | Diff | Hide line numbers
Comments: 0