OOP in C++ module

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kovalski
:warning: Old Version Published before Godot 3 was released.

How can I work with OOP in C++ module to be able to call by functions from GDScript?

For example: Room.get_human().get_name()

Please clarify your question, OOP is quite a wide concept.
Do you want to call C++ functions from GDScript or call GDScript functions from C++? Or something else?

Zylann | 2017-02-12 01:26

I want to call C++ functions from GDScript

Kovalski | 2017-02-12 10:56

:bust_in_silhouette: Reply From: Zylann

In Godot, any class inheriting Object (or Node, Reference etc) have access to a reflection API allowing other languages to call methods on them.
You have to implement _bind_methods() and register your class in ClassDB.

This is covered in the official documentation here Object class — Godot Engine (stable) documentation in English

And this is an example in Godot source code: https://github.com/godotengine/godot/blob/master/scene/2d/sprite.cpp#L295