]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - examples/member_method.cc
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / examples / member_method.cc
1 /* Copyright 2003, The libsigc++ Development Team
2  *
3  *  Assigned to the public domain.  Use as you wish without
4  *  restriction.
5  */
6
7 #include <iostream>
8 #include <string>
9
10 #include <sigc++/sigc++.h>
11
12 class Something : public sigc::trackable
13 {
14 public:
15   Something();
16
17 protected:
18
19   virtual void on_print(int a);
20   
21   typedef sigc::signal<void, int> type_signal_print;
22   type_signal_print signal_print;
23     
24 };
25
26 Something::Something()
27 {
28   auto iter = signal_print.connect( sigc::mem_fun(*this, &Something::on_print) );
29
30   signal_print.emit(2);
31
32   //This isn't necessary - it's just to demonstrate how to disconnect:
33   iter->disconnect();
34   signal_print.emit(3); //Prove that it is no longer connected.
35 }
36
37 void Something::on_print(int a)
38 {
39   std::cout << "on_print recieved: " << a << std::endl;
40 }
41
42 int main()
43 {
44   Something something;  
45   return 0;
46 }