Tim H
2010-07-16 04:22:07 UTC
Hi,
I am working on using the event handler to call a function with a
variable. Basically, I have the 5 cards the user can pick as 5 separate
buttons. I also have a function that will play the ith card when the ith
button is selected. However, I do not want to make 5 functions (1 for
each button) so I made a function (cardButtonClicked(int)) that took in
this variable i. However, based on the documentation of mem_fun
(http://library.gnome.org/devel/libsigc++/stable/group__mem__fun.html#ga23120ad94420b72a8761423c5bab2bec),
I only need to add the initialization list. However, on compile, this
generates the error "invalid use of void expression" except I do not
know which void expression it is mentioning/what's going wrong.
Code (hand[i] is a button, (i) is the variable initialization list):
hand[i].signal_clicked().connect( sigc::mem_fun( *this,
&View::cardButtonClicked )(i) );
Thanks,
Tim Hsiung
I am working on using the event handler to call a function with a
variable. Basically, I have the 5 cards the user can pick as 5 separate
buttons. I also have a function that will play the ith card when the ith
button is selected. However, I do not want to make 5 functions (1 for
each button) so I made a function (cardButtonClicked(int)) that took in
this variable i. However, based on the documentation of mem_fun
(http://library.gnome.org/devel/libsigc++/stable/group__mem__fun.html#ga23120ad94420b72a8761423c5bab2bec),
I only need to add the initialization list. However, on compile, this
generates the error "invalid use of void expression" except I do not
know which void expression it is mentioning/what's going wrong.
Code (hand[i] is a button, (i) is the variable initialization list):
hand[i].signal_clicked().connect( sigc::mem_fun( *this,
&View::cardButtonClicked )(i) );
Thanks,
Tim Hsiung