# Constructor {#Constructor}

A constructor is a special type of member method that is automatically called when a new object of a class is created. The purpose of the constructor is to initialize the member variables, ensuring that the object is in a valid state upon creation. For example, the constructor for class `Person` is defined as follows.

``` {#codeblock_cfc_5wt_4bc}
def Person(name_, age_) {
    name = name_
    age = age_
}
```

**Parent topic:**[Object-Oriented Programming](../../Programming/OOP/ObjectOrientedProgramming.md)

