Well,I have a parent class with a nested class declared in the “protected” tab with a protected class variable.In another unit I have a child class,which inherits from the parent class.When I try to access something protected/public from the parent class -it works,but when I try to access something protected from the nested class,it doesnt work.
type
TParent = class(TObject)
protected
class var x:integer;
type
TNested = class(TObject)
protected
class var y:integer;
end;
end;
My code in the child class:
x := 10; //works
y := 10; //undeclarated idenitifier 'y'.
TNested.y := 10; //undeclarated idenitifier 'y'
the declaration of the child class is:
type
TChild = class(TParent);
How do I access y?
y:integer is a protected field of TNested class, ie. can be only used by TNested and it’s own inherited classes.
You probably may use TNested from TParent but this is beacause in Delphi you may have greater access than it should be if calling from the same unit. So TParent and TNested are in the same unit, so you may call TNested protected data from TParent. But since TChild is in different unit than TNested, it is impossible.