Martin Friebe wrote:
[file foo.pp]
type
  TThat = class(TObject)
   protected
     ThatValue : integer
  end;

  TThis = class(TObject)
    ....
  end;
implementation ...
[/end of file foo.pp]

[file bar.pp]
type
 TThatFake class(TThat)
 end; // intntionally empty class

 TSomething = class(...)
....
[/end of file bar.pp]]

- If TThatFake had any code, then any code belonging to TThatFake would be allowed to see it's anchestor protected members, that would be correct.

Yes. Inheritance.

- If TThatFake had any protected mebers implemented in bar.pp they should be visble to other code in bar.pp

Yes. Friend classes.

- But what about inherited members? Should TSomething be able to access ThatValue?

Yes, if the object pointer is declared as TThatFake or you cast the pointer to TThatFake. Otherwise no, only public members of TThat would be visible.

Joao Morais
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to