Created
March 28, 2021 03:37
-
-
Save lidaobing/f5dec5839606f0e612f95f743c37967d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sigc++/signal.h> | |
using namespace std; | |
class A { | |
public: | |
sigc::signal<void()> s1; | |
}; | |
class B { | |
public: | |
~B() { cout << "B::~B()" << endl; } | |
void onS1() { cout << "B::onS1: SHOULD NOT PRINT" << endl; } | |
}; | |
class C: public sigc::trackable { | |
public: | |
~C() { cout << "C::~C()" << endl; } | |
void onS1() { cout << "WILL NOT PRINT" << endl; } | |
}; | |
int main() { | |
A a; | |
B* b = new B; | |
C* c = new C; | |
a.s1.connect(sigc::mem_fun(*b, &B::onS1)); | |
a.s1.connect(sigc::mem_fun(*c, &C::onS1)); | |
delete b; | |
delete c; | |
a.s1.emit(); | |
} | |
// $ g++ -std=c++11 `pkg-config --cflags --libs sigc++-2.0` sigc_test.cpp | |
// $ ./a.out | |
// B::~B() | |
// C::~C() | |
// B::onS1: SHOULD NOT PRINT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment