but I learn programming and after structured programming with Pascal language, I\'m beginning to learn about OOP with Delphi.
So, I don\'t really understand the diff
One other case missing in the other answers. There are possibilities to "extend" the class encapsulation rules.
With class helpers, introduced in Delphi 8 (for .NET compatibility), it is possible to circumvent the difference in visibility between private,protected and public (and even the strict notations). The class helper declaration can be in another unit than the original class.
This is an example :
type
TMyOrgClass = class
strict private
FMyPrivateProp: Integer;
strict protected
property MyPrivateProp: Integer read FMyPrivateProp;
end;
TMyClassHelper = class helper for TMyOrgClass
private
function GetMyPublicProp: Integer;
public
property MyPublicProp: Integer read GetMyPublicProp;
end;
function TMyClassHelper.GetMyPublicProp: Integer;
begin
Result:= Self.FMyPrivateProp; // Access the org class members with Self
end;
See this post for more information :access-a-strict-protected-property-of-a-delphi-class.