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
Modification of posting from Anonymous Wed 14th Mar 2007 09:32
Download | New Post | Modify | Diff | Hide line numbers
-
#include
-
#include
-
#include
-
#include
-
-
typedef boost::signal
()> MySignal; -
-
class Test : public boost::signals::trackable {
-
public:
-
Test(const std::string &s, MySignal & sgn);
-
-
void operator()();
-
private:
-
std::string str;
-
};
-
-
Test::Test(const std::string &s, MySignal & sgn) {
-
str = s;
-
sgn.connect(*this);
-
}
-
-
void Test::operator()() {
-
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;
-
}
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
Modification of posting from Anonymous Wed 14th Mar 2007 09:32
Download | New Post | Modify | Diff | Hide line numbers
Comments: 0