-1

I used the signal functionality in the boost library fine with functions in the same class, but now I want to signal an object declared in another class.

Here it is:

in my 'inputReader' class I have the following functions:

void setNonTraverse(char key, int x, int y);
void setChest(char key, int x, int y);
void setEntry(char key, int x, int y);
void setExit(char key, int x, int y);

in my code that reads from the keyboard I have:

inputReader readInput;



/* This is setting up our signal for sending observations */
boost::signals2::signal<void (char, int, int)> sig;

/* Subjects the Observer will connect with */
sig.connect(bind(&inputReader::setChest, &readInput ));

But of course.. this is not working.. I tried looking at the documentation, but couldn't find anything. Can anyone help me out?

Gregorio Di Stefano
  • 1,173
  • 1
  • 15
  • 23
  • 1
    See the first accepted answer here http://stackoverflow.com/questions/768351/complete-example-using-boostsignals-for-c-eventing – az4dan Nov 06 '11 at 17:52
  • "This is not working" is not a sufficient description of the problem. – interjay Nov 06 '11 at 18:24
  • I changed my code after seeing what thax pointed out.. but I am still getting a bunch of errors linking. When I mean a bunch of errors, I really mean a lot of errors.. – Gregorio Di Stefano Nov 06 '11 at 18:27
  • Next time please include the errors (or at least the first one), because it makes it a lot easier to find the error. That's what error messages are for! – interjay Nov 06 '11 at 18:31

1 Answers1

0

When using bind, you need to put placeholders for any additional parameters your function takes. In this case, since your function takes 3 parameters:

sig.connect(bind(&inputReader::setChest, &readInput, _1, _2, _3));

You'd need this whether you're doing it in the same class or from a separate object.

interjay
  • 107,303
  • 21
  • 270
  • 254