From cfb3e947f28934fd894a0ab4f130fb5f87d56950 Mon Sep 17 00:00:00 2001 From: alk <45172705+altalk23@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:17:22 +0300 Subject: [PATCH] Update fields.md --- tutorials/fields.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tutorials/fields.md b/tutorials/fields.md index 54c0fdd..1201585 100644 --- a/tutorials/fields.md +++ b/tutorials/fields.md @@ -36,14 +36,20 @@ class $modify(PlayerObject) { This code works even if you have multiple `PlayerObject`s, and the counter is initialized as 0 for each one, providing an elegant yet simple solution to the problem. -**Fields must be accessed through the `m_fields` member**. If you access them directly through `this`, you will get **undefined behaviour** (most likely a crash). +> :warning: If you are using old fields behavior, then **fields must be accessed through the `m_fields` member**. If you access them directly through `this`, you will get **undefined behaviour** (most likely a crash). Fields are declared just like normal member variables, even constructors and destructors work\*. ```cpp class $modify(PlayerObject) { struct Fields { - int m_totalJumps = 13; + Fields() : m_totalJumps(13) { + log::debug("Constructed!"); + } + int m_totalJumps; + ~Fields() { + log::debug("Destructed!"); + } }; void pushButton(PlayerButton button) {