# How to reference an object in another function to its class?

**URL:** <https://discourse.processing.org/t/how-to-reference-an-object-in-another-function-to-its-class/17964>\
**Category:** Beginners\
**Created:** [February 21, 2020, 3:39am UTC](https://discourse.processing.org/t/how-to-reference-an-object-in-another-function-to-its-class/17964 "2020-02-21T03:39:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [February 21, 2020, 5:43am UTC](https://discourse.processing.org/t/how-to-reference-an-object-in-another-function-to-its-class/17964/2 "2020-02-21T05:43:07Z")

</div>

1 way to do it: 👼

```auto
Person squid;

void setup() {
  frameRate(1);
  squid = new Person();
}

void draw() {
  squid.increaseAge(); // alt.: ++squid.age;
  print(squid);
}

class Person {
  int age;

  Person increaseAge() {
    ++age;
    return this;
  }

  String toString() {
    return "Age: " + age + TAB;
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/how-to-reference-an-object-in-another-function-to-its-class/17964)._
