# Do I need to update ClassDef if I change the name of a variable

**URL:** <https://root-forum.cern.ch/t/do-i-need-to-update-classdef-if-i-change-the-name-of-a-variable/64545>\
**Category:** Newbie\
**Created:** [December 18, 2025, 11:22am UTC](https://root-forum.cern.ch/t/do-i-need-to-update-classdef-if-i-change-the-name-of-a-variable/64545 "2025-12-18T11:22:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [December 18, 2025, 11:22am UTC](https://root-forum.cern.ch/t/do-i-need-to-update-classdef-if-i-change-the-name-of-a-variable/64545/1 "2025-12-18T11:22:54Z")

</div>

* * *

_Dear all_

I created a class that derived from `TObject`, and had a `unsigned int A` stored.

After I change the name `A` to `B`, but remain the same type (also I changed some functionalities related to this value, but that’s another story). Do I need to change the number of ClassDef? Because memory structure is not changed I suppose I don’t need to do so?

* * *

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [December 18, 2025, 7:08pm UTC](https://root-forum.cern.ch/t/do-i-need-to-update-classdef-if-i-change-the-name-of-a-variable/64545/2 "2025-12-18T19:08:12Z")

</div>

You need to increment the version number any time the persistent data member change in `type` or `name`. As far as the `I/O` is concerned when you change the name of a variable, it is the same as if you removed a data member and added a completely independent one. In particular if you read an old file the value of `B` will not be be updated (from what it is set in the default constructor). If you need to be able to read the `A` on file into the `B` in memory you need to write an I/O customization rule. For example:

```auto
// Assuming you class is named `NameOfTheClass` and its old version number is `2` and that 
// type of the old member A is `old_type_of_A`.
#pragma read sourceClass="NameOfTheClass" targetClass="NameOfTheClass" version="[2]" source="old_type_of_A A" target="B" code="{ B = onfile.A; }"

```

In the `code` part you would need to apply any transformation needed for the `A` value to make sense as a `B`.

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [December 19, 2025, 1:34am UTC](https://root-forum.cern.ch/t/do-i-need-to-update-classdef-if-i-change-the-name-of-a-variable/64545/3 "2025-12-19T01:34:26Z")

</div>

I see. Thank you!
