Cannot access public variable

I think I’ve made some fundamental error here…
I have a public variable a in class A, and I want to access it in class B, but I cant (access of possibly undefined property…)
what’s wrong here?
now every time I want to refer to a variable in class A I need to pass the variable reference to class B’s constructor