Please confirm this can't be done... lazarus / 62-General ---------------------------------------------------------------------- EganSolo · 2015-06-29 22:40 I know we can declare protected (or private) properties as public in descendant classes, and I thought we could do the same with methods but this does not seem to be the case? Is this true? Here's a bit of code to illustrate what I'm talking about: Code: [Select]  Class1 = class   strict private     fStr : String;     fInt : integer;     function GetStr : String;     function GetInt : Integer;     procedure SetStr(const aValue : String);     procedure SetInt(Const aValue : Integer);   strict protected     function MakeNewKey : String;     property Str : String  read GetStr write SetStr;     property Int : Integer read GetInt write SetInt;   public     constructor create;   end;   Class2 = class(class1)   public     property Str; //this works     property Int; // this works     function MakeNewKey; //this doesn't. It would seem that FPC requires                                         //(a) the full function signature and                                         //(b) its implementation even if does nothing more than calling inherited? Right?   end; ---------------------------------------------------------------------- taazz · 2015-06-29 22:50 I don't see it. what this suppose not to do? ---------------------------------------------------------------------- EganSolo · 2015-06-29 23:00 It's trying to redeclare the function MakeNewKey public in Class2 where it is strict protected. See how we can do that with properties? We can redeclare them public in class2 without having to reimplement them but it does not look like we can do the same with methods. In other words, even when we are simply changing the visibility of a method between a class and its descendant, we have to implement that method, even if we are not introducing any new behavior. Does this make sense? I'm trying to confirm that this is case. ---------------------------------------------------------------------- lainz · 2015-06-29 23:02 Quote from: taazz on June 30, 2015, 12:50:57 amI don't see it. what this suppose not to do? Code: [Select]function MakeNewKey; //this doesn't. It would seem that FPC requires                                         //(a) the full function signature and                                         //(b) its implementation even if does nothing more than calling inherited? Right? But I don't know the answer. He wants to know if he can do public an inherited protected function Code: [Select]function MakeNewKey; with that code. Or if requires the full signature Code: [Select]function MakeNewKey : String;. I don't have FPC here to test. ---------------------------------------------------------------------- taazz · 2015-06-29 23:33 http://stackoverflow.com/questions/8232990/best-approach-to-elevate- method-visibility-in-a-descendant-class definite answer to your question. So no there is no mechanism that would allow you to change the visibility of a method as you can with properties.