Bypass the protection level

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 11 08:22:42 PDT 2015


On 03/11/2015 04:40 AM, Namespace wrote:

 > I can call draw on Drawable, because it is declared public and I cannot
 > call draw on Sprite because it is declared protected (this is already a
 > bit weird, why can I redeclare the interface method draw as protected?)

It is the same in C++.

 > but I can call the protected draw method from Sprite through Drawable.
 > Is this intended?

As far as I know, yes it's intended and again the same in C++.

Ali



More information about the Digitalmars-d-learn mailing list