# Cannot access public variable

**URL:** https://forum.kirupa.com/t/cannot-access-public-variable/300838
**Category:** Uncategorized
**Created:** [November 28, 2009, 5:35pm UTC](https://forum.kirupa.com/t/cannot-access-public-variable/300838 "2009-11-28T17:35:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![OMG](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@OMG](https://forum.kirupa.com/u/OMG)
#### Post date: [November 28, 2009, 5:35pm UTC](https://forum.kirupa.com/t/cannot-access-public-variable/300838/1 "2009-11-28T17:35:47Z")

</div>

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
