0

What does the keyword protected do?

I have been learning about private protected and public and I don't fully understand what protected means

18th Dec 2017, 3:20 AM
jeff
jeff - avatar
1 Resposta
+ 2
Private you can access only from this class itself. If you inherited from this class, you still can't see it from inherited class. Protected used when you need something available for inherited classes also. Example: class A {private static int a; protected static int b;} class B:A{ public static void main(string str) {a=1; //should show error b=1; //should be ok }
18th Dec 2017, 3:34 AM
Dima Makieiev
Dima Makieiev - avatar