I was following the official documentation for libsigc++-2.0
and I found this example:
class AlienDetector
{
public:
AlienDetector();
void run();
sigc::signal<void> signal_detected;
};
void warn_people()
{
cout << "There are aliens in the carpark!" << endl;
}
int main()
{
AlienDetector mydetector;
mydetector.signal_detected.connect( sigc::ptr_fun(warn_people) );
mydetector.run();
return 0;
}
As you can see both the run()
function and the constructor for the AlienDetector
class are not defined and therefore this code shouldn't compile ( but the doc takes for granted the fact that this code will work ).
Even more strange is the fact that if I define both run()
and the constructor for the class, I can't see the effect of the library anyway, apparently the signal doesn't work and when run
is called in the main
no slot is activated.
I am forgetting about something here ? How this thing should be re-written ?
The documentation seems to be incomplete.
The most basic version of the code should look like:
I've posted a fully functional make-based example on github, example1.cpp is the first example, example2.cpp is one using a member function.