+ 1

If I have a class A , class B and create an object of A in the main class( example A.yell()). How can access this opject of the

A class out of the B class?

26th Nov 2017, 3:38 PM
jack
jack - avatar
9 odpowiedzi
+ 1
does anyone have an idea?
26th Nov 2017, 3:54 PM
jack
jack - avatar
+ 1
best way is to use inheritance where you can use super() so you use menu as super class and use it as parent class in submenu so you can just use super method to access parent properties
26th Nov 2017, 11:09 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
0
for better understanding can post sample code jsut structure please because it's confusing
26th Nov 2017, 4:30 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
0
ok wait a mom
26th Nov 2017, 4:32 PM
jack
jack - avatar
26th Nov 2017, 5:00 PM
jack
jack - avatar
0
hai in your menu1 case 1 I see you called sub1 after beak which will not work so put it on top of beak
26th Nov 2017, 5:04 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
0
I changed but how I get acces to the m.menu1 object out of the submenu class
26th Nov 2017, 5:30 PM
jack
jack - avatar
0
after it prints in submenu it will go back to menu1 as it is the caller so if print anything after calling submenu in menu1 you will get it printed
26th Nov 2017, 6:01 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
0
but the m.menu1 is an object of the main class. how can I use the existing object in the submenuclass
26th Nov 2017, 6:21 PM
jack
jack - avatar