# Help needed regarding visibility

**URL:** https://community.haxe.org/t/help-needed-regarding-visibility/2458
**Category:** Haxe
**Created:** [May 21, 2020, 5:30pm UTC](https://community.haxe.org/t/help-needed-regarding-visibility/2458 "2020-05-21T17:30:19Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![gccc](https://avatars.discourse-cdn.com/v2/letter/g/ce73a5/32.png) [@gccc](https://community.haxe.org/u/gccc)
#### Post date: [May 21, 2020, 5:30pm UTC](https://community.haxe.org/t/help-needed-regarding-visibility/2458/1 "2020-05-21T17:30:19Z")

</div>

i was testing with class instantiation and everything worked until i tried to implement

```haxe
public var total = add();

```

and came to an error regarding the call to add() function :  
Cannot access this or other member field in variable initialization  
according to my understanding of visibility, private function add() and variables a and b should be accessible to the call in the same class, so im kinda confused. any help is appreciated!

```haxe
class Main{
  static function main() {
    var ans = new X(5,6);
   trace(ans.total);
  
    
}
}
class X{

var a:Int;
var b:Int;
public var total = add();
public function new(a,b)
  {
  this.a=a;
  this.b=b;
}
function add()
  {
  return a+b;
}

}

```

---

_[View the full topic](https://community.haxe.org/t/help-needed-regarding-visibility/2458)._
