# see protected-errors.cobra for error messages about protected access class A var _a as A? cue init base.init def pub1 pass def pub2(i as int) pass def prot1 is protected pass def prot2(i as int) is protected pass def priv1 is private pass def priv2(i as int) is private pass def invokeA if _a _a.pub1 _a.pub2(5) _a.prot1 _a.prot2(5) _a.priv1 _a.priv2(5) A().pub1 A().pub2(5) A().prot1 A().prot2(5) A().priv1 A().priv2(5) B().pub1 B().pub2(5) B().prot1 B().prot2(5) B().priv1 B().priv2(5) C().pub1 C().pub2(5) C().prot1 C().prot2(5) C().priv1 C().priv2(5) class B inherits A cue init base.init def invokeB if _a _a.pub1 _a.pub2(5) # _a.prot1 # _a.prot2(5) # _a.priv1 # _a.priv2(5) A().pub1 A().pub2(5) # A().prot1 # A().prot2(5) # A().priv1 # A().priv2(5) B().pub1 B().pub2(5) B().prot1 B().prot2(5) # B().priv1 # B().priv2(5) C().pub1 C().pub2(5) C().prot1 C().prot2(5) # C().priv1 # C().priv2(5) class C inherits B cue init base.init def invokeC if _a _a.pub1 _a.pub2(5) # _a.prot1 # _a.prot2(5) # _a.priv1 # _a.priv2(5) A().pub1 A().pub2(5) # A().prot1 # A().prot2(5) # A().priv1 # A().priv2(5) B().pub1 B().pub2(5) # B().prot1 # B().prot2(5) # B().priv1 # B().priv2(5) C().pub1 C().pub2(5) C().prot1 C().prot2(5) # C().priv1 # C().priv2(5) class AG var _a as AG? cue init base.init def pub1 pass def pub2(i as int) pass def prot1 is protected pass def prot2(i as int) is protected pass def priv1 is private pass def priv2(i as int) is private pass def invokeA if _a _a.pub1 _a.pub2(5) _a.prot1 _a.prot2(5) _a.priv1 _a.priv2(5) AG().pub1 AG().pub2(5) AG().prot1 AG().prot2(5) AG().priv1 AG().priv2(5) BG().pub1 BG().pub2(5) BG().prot1 BG().prot2(5) BG().priv1 BG().priv2(5) CG().pub1 CG().pub2(5) CG().prot1 CG().prot2(5) CG().priv1 CG().priv2(5) class BG inherits AG cue init base.init def invokeB if _a _a.pub1 _a.pub2(5) # _a.prot1 # _a.prot2(5) # _a.priv1 # _a.priv2(5) AG().pub1 AG().pub2(5) # AG().prot1 # AG().prot2(5) # AG().priv1 # AG().priv2(5) BG().pub1 BG().pub2(5) BG().prot1 BG().prot2(5) # BG().priv1 # BG().priv2(5) CG().pub1 CG().pub2(5) CG().prot1 CG().prot2(5) # CG().priv1 # CG().priv2(5) class CG inherits BG cue init base.init def invokeC if _a _a.pub1 _a.pub2(5) # _a.prot1 # _a.prot2(5) # _a.priv1 # _a.priv2(5) AG().pub1 AG().pub2(5) # AG().prot1 # AG().prot2(5) # AG().priv1 # AG().priv2(5) BG().pub1 BG().pub2(5) # BG().prot1 # BG().prot2(5) # BG().priv1 # BG().priv2(5) CG().pub1 CG().pub2(5) CG().prot1 CG().prot2(5) # CG().priv1 # CG().priv2(5) class Program def main a = A() a.pub1 a.pub2(5) a.invokeA b = B() b.pub1 b.pub2(5) b.invokeA b.invokeB c = C() c.pub1 c.pub2(5) c.invokeA c.invokeB c.invokeC ag = AG() ag.pub1 ag.pub2(5) ag.invokeA bg = BG() bg.pub1 bg.pub2(5) bg.invokeA bg.invokeB cg = CG() cg.pub1 cg.pub2(5) cg.invokeA cg.invokeB cg.invokeC