Identifyer visibility: program, subprogram, unit, class, private/public etc. lazarus / 21-General ---------------------------------------------------------------------- Researching · 2022-09-01 08:16 Visibility is convenient for avoiding bugs, debugging, readability of code etc. But, what is the complete hierarchy? - program- subprogram, - unit,  - library(exported...),  - class,  - private/public/published/protected/  - etc. // for example what will happen if two classes declared in the same unit? // inherit from a class in library? // inheritance through "exported" - is it possible? Maybe all these things are described in documents, but did not find all stuff in the same place. For example: made a code in two units: first - main of program second - unit with reusable subprograms And could not make a proper typecast: same declaration in different units was considered as different types. The solution was elementary: declare the  type in a separate unit and include it in in both: first and second units. But this took a couple of hours to find out. And how many more combinations are possible?... So could anyone explain the whole concept of FPC visibility of identifiers? ---------------------------------------------------------------------- Thaddy · 2022-09-01 08:22 See the documentation (as usual): https://www.freepascal.org/docs-html/ref/refse35.html ---------------------------------------------------------------------- Researching · 2022-09-01 08:24 1. Strict private - you mean protected? And that about RTTI - is one of things hardly found in docs. Very valuable answer ---------------------------------------------------------------------- Thaddy · 2022-09-01 08:28 Nope, see my above edit and the docs: https://www.freepascal.org/docs-html/ref/refse35.html That is about the same as I wrote before the edit. ---------------------------------------------------------------------- Researching · 2022-09-01 08:52 Oh, if could bring back that first version of your topic... It was clear and simple for initial comprehension. Have seen the docs on the link provided... Docs are usually peculiarly detailed, and mostly require either big knowledge or lots of time to get on with. ... So could you please return the initial version of your post? ---------------------------------------------------------------------- KodeZwerg · 2022-09-01 10:38 Maybe it help you when you simply create a "Father" class and from that in a different unit a "Son" class, try having all possible visibilities included and try access them. "Learning by doing..." for units in general, everything between "interface" and "implementation" will be accessible from other units that "uses" that. ---------------------------------------------------------------------- Thaddy · 2022-09-01 12:48 Quote from: Researching on September 01, 2022, 10:52:00 amOh, if could bring back that first version of your topic... Ok, but the manual is clear, I think. But here's the old version that I removed in my edit: 1. strict private : only accessible from the class itself, but not through inheritance. 2. private : only accessible from the unit where it is declared, also by other classes in the same unit but not through inheritance from other units 3. strict protected : only accessible by the class itself or through inheritance, inheritance can make it public or published (promote visibility) 4. protected : only accessible by inheritance or from within the same unit, inheritance can make it public or published (promote visibility) 5. public : accessible anywhere 6. published : accessible anywhere and has type information generated (RTTI)  so it can e.g. be used by the IDE ($M+}, RTTI has more applications btw. This is more or less the same as the manual and I should have referred to the manual in the first place. That is why I removed it and replaced it with the link to the manual. ---------------------------------------------------------------------- Researching · 2022-09-01 21:09 Thank you, Thaddy.