Overriding Property lazarus / 62-General ---------------------------------------------------------------------- Weitentaaal · 2021-12-16 07:09 Hello, I did override my Property Setter. works fine but when my Superclass Setter is private i do get this Error Message: uswdata.pas(58,17) Error: There is no method in an ancestor class to be overridden: "SetLumeng(Double);" If i set it to protected i get this warning: uswdata.pas(58,17) Note: Virtual method "SetLumeng(Double);" has a lower visibility (private) than parent class TBauteil (protected) Setter/Getter  should be private and after the documentation ("https://www.freepascal.org/docs-html/ref/refsu39.html") i did it correctly. HereTheCode Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //Superclassprotected   procedure SetLumeng(AValue: Double); virtual; //Setter i want to override / if its protected i get no error but this Note / if its private i get an error (but shouldn't be the    Setter private ?) public   property Lumeng: Double read GetLumeng write SetLumeng; implementation function TBauteil.GetLumeng: Double;begin  Result:= fLumengend; procedure TBauteil.SetLumeng(AValue: Double);begin   if fLumeng=AValue then Exit;   fLumeng:=AValue;end; //SubClassprivate      procedure SetLumeng(AValue: Double); override; implementation procedure TSWViewModel.SetLumeng(AValue: Double);begin   if Lumeng=AValue then Exit;   Inherited SetLumeng(AValue);    WhenLGetChangedDoThis();end;   Any help would be welcome, thanks in advance. ---------------------------------------------------------------------- PascalDragon · 2021-12-16 08:01 Quote from: Weitentaaal on December 16, 2021, 08:09:44 amI did override my Property Setter. works fine but when my Superclass Setter is private i do get this Error Message: uswdata.pas(58,17) Error: There is no method in an ancestor class to be overridden: "SetLumeng(Double);" That is correct. Anything you want to use in a descendant class if that class isn't in the same unit (or the fields/methods in question are declared as strict private) must be (strict) protected or of higher visibility. Quote from: Weitentaaal on December 16, 2021, 08:09:44 amIf i set it to protected i get this warning: uswdata.pas(58,17) Note: Virtual method "SetLumeng(Double);" has a lower visibility (private) than parent class TBauteil (protected) That is correct, cause it makes no sense to lower the visibility in a descendant class, because by using the parent class one can access it nevertheless. Quote from: Weitentaaal on December 16, 2021, 08:09:44 amSetter/Getter  should be private and after the documentation ("https://www.freepascal.org/docs-html/ref/refsu39.html") i did it correctly. No. While the example puts the field into the private section what you use for the getter and setter can effectively be at any visibility independent of the property's visibility (though it makes most sense to use a lower visibility). That example only works because all the classes are used in the same module (so yes, that should be improved to be a bit more general). TL;DR: If you want to access or adjust fields/methods/properties in a descendant then these need to be of (strict) protected or higher visibility. ---------------------------------------------------------------------- Weitentaaal · 2021-12-16 08:43 Quote from: PascalDragon on December 16, 2021, 09:01:40 amQuote from: Weitentaaal on December 16, 2021, 08:09:44 amI did override my Property Setter. works fine but when my Superclass Setter is private i do get this Error Message: uswdata.pas(58,17) Error: There is no method in an ancestor class to be overridden: "SetLumeng(Double);" That is correct. Anything you want to use in a descendant class if that class isn't in the same unit (or the fields/methods in question are declared as strict private) must be (strict) protected or of higher visibility. Quote from: Weitentaaal on December 16, 2021, 08:09:44 amIf i set it to protected i get this warning: uswdata.pas(58,17) Note: Virtual method "SetLumeng(Double);" has a lower visibility (private) than parent class TBauteil (protected) That is correct, cause it makes no sense to lower the visibility in a descendant class, because by using the parent class one can access it nevertheless. Quote from: Weitentaaal on December 16, 2021, 08:09:44 amSetter/Getter  should be private and after the documentation ("https://www.freepascal.org/docs-html/ref/refsu39.html") i did it correctly. No. While the example puts the field into the private section what you use for the getter and setter can effectively be at any visibility independent of the property's visibility (though it makes most sense to use a lower visibility). That example only works because all the classes are used in the same module (so yes, that should be improved to be a bit more general). TL;DR: If you want to access or adjust fields/methods/properties in a descendant then these need to be of (strict) protected or higher visibility. thanks for the clarification, answered everything i wanted. Thanks again @PascalDragon.