I am trying to access a function from a class from within a class it was not created in.
Basically I have class A which can do b.refresh();
b obviously contains that function known as refresh. I now want class C to access it.
So in my mind it would be something like c.b.refresh(); but this clearly doesn’t work.
What would I need to do to make it work? Only one instance of B is allowed.
Main class:
B b = new b();
b.refresh();
C c = new C();
Inside C:
function() {
//want to access the same b from Main class.
}
I assume you want to share the B instance so :
now you can do :
And the same you can do with the A class passing the same B instance as :