# Override not work? (itk5)

**URL:** <https://discourse.itk.org/t/override-not-work-itk5/2268>\
**Category:** Uncategorized\
**Created:** [September 26, 2019, 8:16am UTC](https://discourse.itk.org/t/override-not-work-itk5/2268 "2019-09-26T08:16:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hothao](https://discourse.itk.org/user_avatar/discourse.itk.org/hothao/32/923_2.png) [@hothao](https://discourse.itk.org/u/hothao)\
**Post date:** [September 26, 2019, 8:16am UTC](https://discourse.itk.org/t/override-not-work-itk5/2268/1 "2019-09-26T08:16:12Z")

</div>

Hi everyone!  
I’m trying to run my code by ITK newest version 5. But I got this error. Can you help me fix it?

```nohighlight
/home/itkReadParameters.h: In instantiation of ‘class itk::RegistrationParameters<3>’:
/home/DeformableRegistration.h:140:60: required from ‘class itk::DeformableRegistration<short int, 3>’
/home/BSplineRegistration.cxx:251:72: required from here
/opt/InsightToolkit-5.0.1/Modules/Core/Common/include/itkMacro.h:359:15: error: ‘const char* itk::RegistrationParameters<ImageDimension>::GetNameOfClass() const [with unsigned int ImageDimension = 3]’ marked ‘override’, but does not override
   const char *GetNameOfClass() const override \
               ^
/home/sbin/itkReadParameters.h:187:3: note: in expansion of macro ‘itkTypeMacro’
   itkTypeMacro(RegistrationParameters, None);

```

Thanks!

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [September 26, 2019, 1:57pm UTC](https://discourse.itk.org/t/override-not-work-itk5/2268/2 "2019-09-26T13:57:32Z")

</div>

I don’t remember anything done to `GetNameOfClass` method in v4 to v5 transition. Perhaps you should look at the migration guide, especially section [Legacy code removed](https://github.com/InsightSoftwareConsortium/ITK/blob/dd80baf3387194e4b561c0ec5c675a65b0409b96/Documentation/ITK5MigrationGuide.md#legacy-code-removed).

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [September 26, 2019, 2:05pm UTC](https://discourse.itk.org/t/override-not-work-itk5/2268/3 "2019-09-26T14:05:07Z")

</div>

You might want to use [itkTypeMacroNoParent](https://github.com/InsightSoftwareConsortium/ITK/blob/2b82a99b888657fb5edcc7f02ae576860ac33b10/Modules/Core/Common/include/itkMacro.h#L356) instead of `itkTypeMacro` in _itkReadParameters.h:187_.

---

<div class="post-metadata">

**Author:** ![hothao](https://discourse.itk.org/user_avatar/discourse.itk.org/hothao/32/923_2.png) [@hothao](https://discourse.itk.org/u/hothao)\
**Post date:** [September 28, 2019, 5:39am UTC](https://discourse.itk.org/t/override-not-work-itk5/2268/4 "2019-09-28T05:39:07Z")

</div>

Thank you. I tried with itkTypeMacroNoParent, but it still doesn’t work.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [September 28, 2019, 4:33pm UTC](https://discourse.itk.org/t/override-not-work-itk5/2268/5 "2019-09-28T16:33:09Z")

</div>

What is the declaration of your class `itkReadParameters`? And what is the new error? Does enabling/disabling legacy when compiling ITK matter in ITKv4? What about ITKv5?
