Page 1 of 1

Binding issue: uninitialized local variable

Posted: Tue Aug 13, 2019 3:58 pm
by bandali99
Hi, I created a separate window and I want to connect it to a widget on another window. I used the bind function and included the header files but when I run the file "uninitialized local variable" error appeared. What did I do wrong?

Code: Select all

slidercontrol* checkslider;
	selectedslider = checkslider->getselect();
This may not be enough code to look at so here is the git link too, the cpp files I am referring to are selectslidercontrol and mysingleslider (line 143).

https://github.com/fahadbandali/multi-slider

thanks

Re: Binding issue: uninitialized local variable

Posted: Tue Aug 13, 2019 4:09 pm
by alys666
you just declared "checkslider", but not assigned any value to it. and later use it as something assigned.
for example if you declared:

int my_burth_date;

how your real birth date was assigned to it?

Re: Binding issue: uninitialized local variable

Posted: Tue Aug 13, 2019 4:21 pm
by bandali99
alys666 wrote:
Tue Aug 13, 2019 4:09 pm
you just declared "checkslider", but not assigned any value to it. and later use it as something assigned.
for example if you declared:

int my_burth_date;

how your real birth date was assigned to it?
The checkslider object has dynamically changing values based on what the user check marks on that window. If the user checks slide 1 then the value of checkslider would be one. Did I call or bind it incorrectly?

Re: Binding issue: uninitialized local variable

Posted: Tue Aug 13, 2019 4:38 pm
by alys666
where you created this object? you just declared pointer to this object, not created object itself.
whre is something like -

Code: Select all

slidercontrol* checkslider = new slidercontrol(...);

Re: Binding issue: uninitialized local variable

Posted: Tue Aug 13, 2019 4:46 pm
by bandali99
alys666 wrote:
Tue Aug 13, 2019 4:38 pm
where you created this object? you just declared pointer to this object, not created object itself.
whre is something like -

Code: Select all

slidercontrol* checkslider = new slidercontrol(...);
Just tried that and there are no errors in the code now however when I run it the widget and the checkbox are not linked at all..

Code: Select all

Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select1, main, ID_SLIDE1);
	Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select2, main, ID_SLIDE2);
	Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select3, main, ID_SLIDE3);
	Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select4, main, ID_SLIDE4);
Here is how I binded the function to the code in selectslidercontrol and in mysingle slider I used #include "selectslidercontrol" did I do enough to link the two cpp files together?

Re: Binding issue: uninitialized local variable

Posted: Tue Aug 13, 2019 5:05 pm
by alys666
if your programm was successfully linked and you have it runing - all your needed files were linked in executable file. So calm down.

I do not understand an idea of your Bind(....), i just see that your attached 4 handlers to one event. and it looks odd. :)

ps.
also "main" in this lines looks strange... check which methods of which objects, you're attaching to some event source.

Code: Select all

Bind(wxEVT_COMMAND_MENU_SELECTED, &slidercontrol::select2, main, ID_SLIDE2);